dolibarr  9.0.0
list.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2002-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
4  * Copyright (C) 2004-2016 Laurent Destailleur <eldy@users.sourceforge.net>
5  * Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
6  * Copyright (C) 2005-2015 Regis Houssin <regis.houssin@inodbox.com>
7  * Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
8  * Copyright (C) 2010-2012 Juanjo Menent <jmenent@2byte.es>
9  * Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr>
10  * Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
11  * Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr>
12  * Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
13  * Copyright (C) 2015-2016 Ferran Marcet <fmarcet@2byte.es>
14  * Copyright (C) 2017 Josep Lluís Amador <joseplluis@lliuretic.cat>
15  *
16  * This program is free software; you can redistribute it and/or modify
17  * it under the terms of the GNU General Public License as published by
18  * the Free Software Foundation; either version 3 of the License, or
19  * (at your option) any later version.
20  *
21  * This program is distributed in the hope that it will be useful,
22  * but WITHOUT ANY WARRANTY; without even the implied warranty of
23  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24  * GNU General Public License for more details.
25  *
26  * You should have received a copy of the GNU General Public License
27  * along with this program. If not, see <http://www.gnu.org/licenses/>.
28  */
29 
36 require '../../main.inc.php';
37 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
38 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
39 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
40 require_once DOL_DOCUMENT_ROOT.'/core/modules/facture/modules_facture.php';
41 require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
42 require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
43 require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php';
44 require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
45 require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
46 require_once DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php';
47 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
48 require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
49 require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
50 if (! empty($conf->commande->enabled)) require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
51 
52 // Load translation files required by the page
53 $langs->loadLangs(array('bills', 'companies', 'products', 'categories'));
54 
55 $sall=trim((GETPOST('search_all', 'alphanohtml')!='')?GETPOST('search_all', 'alphanohtml'):GETPOST('sall', 'alphanohtml'));
56 $projectid=(GETPOST('projectid')?GETPOST('projectid','int'):0);
57 
58 $id=(GETPOST('id','int')?GETPOST('id','int'):GETPOST('facid','int')); // For backward compatibility
59 $ref=GETPOST('ref','alpha');
60 $socid=GETPOST('socid','int');
61 
62 $action=GETPOST('action','alpha');
63 $massaction=GETPOST('massaction','alpha');
64 $show_files=GETPOST('show_files','int');
65 $confirm=GETPOST('confirm','alpha');
66 $toselect = GETPOST('toselect', 'array');
67 $contextpage=GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'invoicelist';
68 
69 $lineid=GETPOST('lineid','int');
70 $userid=GETPOST('userid','int');
71 $search_product_category=GETPOST('search_product_category','int');
72 $search_ref=GETPOST('sf_ref')?GETPOST('sf_ref','alpha'):GETPOST('search_ref','alpha');
73 $search_refcustomer=GETPOST('search_refcustomer','alpha');
74 $search_type=GETPOST('search_type','int');
75 $search_project=GETPOST('search_project','alpha');
76 $search_societe=GETPOST('search_societe','alpha');
77 $search_montant_ht=GETPOST('search_montant_ht','alpha');
78 $search_montant_vat=GETPOST('search_montant_vat','alpha');
79 $search_montant_localtax1=GETPOST('search_montant_localtax1','alpha');
80 $search_montant_localtax2=GETPOST('search_montant_localtax2','alpha');
81 $search_montant_ttc=GETPOST('search_montant_ttc','alpha');
82 $search_status=GETPOST('search_status','intcomma');
83 $search_paymentmode=GETPOST('search_paymentmode','int');
84 $search_town=GETPOST('search_town','alpha');
85 $search_zip=GETPOST('search_zip','alpha');
86 $search_state=trim(GETPOST("search_state"));
87 $search_country=GETPOST("search_country",'int');
88 $search_type_thirdparty=GETPOST("search_type_thirdparty",'int');
89 $search_user = GETPOST('search_user','int');
90 $search_sale = GETPOST('search_sale','int');
91 $search_day = GETPOST('search_day','int');
92 $search_month = GETPOST('search_month','int');
93 $search_year = GETPOST('search_year','int');
94 $search_day_lim = GETPOST('search_day_lim','int');
95 $search_month_lim = GETPOST('search_month_lim','int');
96 $search_year_lim = GETPOST('search_year_lim','int');
97 $search_categ_cus=trim(GETPOST("search_categ_cus",'int'));
98 $search_btn=GETPOST('button_search','alpha');
99 $search_remove_btn=GETPOST('button_removefilter','alpha');
100 
101 $option = GETPOST('search_option');
102 if ($option == 'late') {
103  $search_status = '1';
104 }
105 $filtre = GETPOST('filtre','alpha');
106 
107 $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
108 $sortfield = GETPOST("sortfield",'alpha');
109 $sortorder = GETPOST("sortorder",'alpha');
110 $page = GETPOST("page",'int');
111 if (empty($page) || $page == -1 || !empty($search_btn) || !empty($search_remove_btn) || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1
112 $offset = $limit * $page;
113 if (! $sortorder && ! empty($conf->global->INVOICE_DEFAULT_UNPAYED_SORT_ORDER) && $search_status == '1') $sortorder=$conf->global->INVOICE_DEFAULT_UNPAYED_SORT_ORDER;
114 if (! $sortorder) $sortorder='DESC';
115 if (! $sortfield) $sortfield='f.datef';
116 $pageprev = $page - 1;
117 $pagenext = $page + 1;
118 
119 // Security check
120 $fieldid = (! empty($ref)?'facnumber':'rowid');
121 if (! empty($user->societe_id)) $socid=$user->societe_id;
122 $result = restrictedArea($user, 'facture', $id,'','','fk_soc',$fieldid);
123 
124 $diroutputmassaction=$conf->facture->dir_output . '/temp/massgeneration/'.$user->id;
125 
126 $object=new Facture($db);
127 
128 $now=dol_now();
129 
130 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
131 $object = new Facture($db);
132 $hookmanager->initHooks(array('invoicelist'));
133 $extrafields = new ExtraFields($db);
134 
135 // fetch optionals attributes and labels
136 $extralabels = $extrafields->fetch_name_optionals_label('facture');
137 $search_array_options=$extrafields->getOptionalsFromPost($object->table_element,'','search_');
138 
139 // List of fields to search into when doing a "search in all"
140 $fieldstosearchall = array(
141  'f.facnumber'=>'Ref',
142  'f.ref_client'=>'RefCustomer',
143  'pd.description'=>'Description',
144  's.nom'=>"ThirdParty",
145  'f.note_public'=>'NotePublic',
146 );
147 if (empty($user->socid)) $fieldstosearchall["f.note_private"]="NotePrivate";
148 
149 $checkedtypetiers=0;
150 $arrayfields=array(
151  'f.facnumber'=>array('label'=>"Ref", 'checked'=>1),
152  'f.ref_client'=>array('label'=>"RefCustomer", 'checked'=>1),
153  'f.type'=>array('label'=>"Type", 'checked'=>0),
154  'f.date'=>array('label'=>"DateInvoice", 'checked'=>1),
155  'f.date_lim_reglement'=>array('label'=>"DateDue", 'checked'=>1),
156  'p.ref'=>array('label'=>"ProjectRef", 'checked'=>0, 'enabled'=>(empty($conf->projet->enabled)?0:1)),
157  's.nom'=>array('label'=>"ThirdParty", 'checked'=>1),
158  's.town'=>array('label'=>"Town", 'checked'=>1),
159  's.zip'=>array('label'=>"Zip", 'checked'=>1),
160  'state.nom'=>array('label'=>"StateShort", 'checked'=>0),
161  'country.code_iso'=>array('label'=>"Country", 'checked'=>0),
162  'typent.code'=>array('label'=>"ThirdPartyType", 'checked'=>$checkedtypetiers),
163  'f.fk_mode_reglement'=>array('label'=>"PaymentMode", 'checked'=>1),
164  'f.total_ht'=>array('label'=>"AmountHT", 'checked'=>1),
165  'f.total_vat'=>array('label'=>"AmountVAT", 'checked'=>0),
166  'f.total_localtax1'=>array('label'=>$langs->transcountry("AmountLT1", $mysoc->country_code), 'checked'=>0, 'enabled'=>($mysoc->localtax1_assuj=="1")),
167  'f.total_localtax2'=>array('label'=>$langs->transcountry("AmountLT2", $mysoc->country_code), 'checked'=>0, 'enabled'=>($mysoc->localtax2_assuj=="1")),
168  'f.total_ttc'=>array('label'=>"AmountTTC", 'checked'=>0),
169  'dynamount_payed'=>array('label'=>"Received", 'checked'=>0),
170  'rtp'=>array('label'=>"Rest", 'checked'=>0),
171  'f.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>500),
172  'f.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>500),
173  'f.fk_statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000),
174 );
175 // Extra fields
176 if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
177 {
178  foreach($extrafields->attribute_label as $key => $val)
179  {
180  if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>(abs($extrafields->attribute_list[$key])!=3 && $extrafields->attribute_perms[$key]));
181  }
182 }
183 
184 
185 /*
186  * Actions
187  */
188 
189 if (GETPOST('cancel','alpha')) { $action='list'; $massaction=''; }
190 if (! GETPOST('confirmmassaction','alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; }
191 
192 $parameters=array('socid'=>$socid);
193 $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
194 if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
195 
196 include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
197 
198 // Do we click on purge search criteria ?
199 if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter','alpha') || GETPOST('button_removefilter.x','alpha')) // All tests are required to be compatible with all browsers
200 {
201  $search_user='';
202  $search_sale='';
203  $search_product_category='';
204  $search_ref='';
205  $search_refcustomer='';
206  $search_type='';
207  $search_project='';
208  $search_societe='';
209  $search_montant_ht='';
210  $search_montant_vat='';
211  $search_montant_localtax1='';
212  $search_montant_localtax2='';
213  $search_montant_ttc='';
214  $search_status='';
215  $search_paymentmode='';
216  $search_town='';
217  $search_zip="";
218  $search_state="";
219  $search_type='';
220  $search_country='';
221  $search_type_thirdparty='';
222  $search_day='';
223  $search_year='';
224  $search_month='';
225  $option='';
226  $filter='';
227  $search_day_lim='';
228  $search_year_lim='';
229  $search_month_lim='';
230  $toselect='';
231  $search_array_options=array();
232  $search_categ_cus=0;
233 }
234 
235 if (empty($reshook))
236 {
237  $objectclass='Facture';
238  $objectlabel='Invoices';
239  $permtoread = $user->rights->facture->lire;
240  $permtocreate = $user->rights->facture->creer;
241  $permtodelete = $user->rights->facture->supprimer;
242  $uploaddir = $conf->facture->dir_output;
243  include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
244 }
245 
246 if ($massaction == 'withdrawrequest')
247 {
248  $langs->load("withdrawals");
249 
250  if (!$user->rights->prelevement->bons->creer)
251  {
252  $error++;
253  setEventMessages($langs->trans("NotEnoughPermissions"), null, 'errors');
254  }
255  else
256  {
257  //Checking error
258  $error = 0;
259 
260  $arrayofselected=is_array($toselect)?$toselect:array();
261  $listofbills=array();
262  foreach($arrayofselected as $toselectid)
263  {
264  $objecttmp=new Facture($db);
265  $result=$objecttmp->fetch($toselectid);
266  if ($result > 0)
267  {
268  $totalpaye = $objecttmp->getSommePaiement();
269  $totalcreditnotes = $objecttmp->getSumCreditNotesUsed();
270  $totaldeposits = $objecttmp->getSumDepositsUsed();
271  $objecttmp->resteapayer = price2num($objecttmp->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits,'MT');
272  if($objecttmp->paye || $objecttmp->resteapayer==0){
273  $error++;
274  setEventMessages($objecttmp->ref.' '.$langs->trans("AlreadyPaid"), $objecttmp->errors, 'errors');
275  } else if($objecttmp->resteapayer<0){
276  $error++;
277  setEventMessages($objecttmp->ref.' '.$langs->trans("AmountMustBePositive"), $objecttmp->errors, 'errors');
278  }
279  if (!($objecttmp->statut > Facture::STATUS_DRAFT)){
280  $error++;
281  setEventMessages($objecttmp->ref.' '.$langs->trans("Draft"), $objecttmp->errors, 'errors');
282  }
283 
284  $rsql = "SELECT pfd.rowid, pfd.traite, pfd.date_demande as date_demande";
285  $rsql .= " , pfd.date_traite as date_traite";
286  $rsql .= " , pfd.amount";
287  $rsql .= " , u.rowid as user_id, u.lastname, u.firstname, u.login";
288  $rsql .= " FROM ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd";
289  $rsql .= " , ".MAIN_DB_PREFIX."user as u";
290  $rsql .= " WHERE fk_facture = ".$objecttmp->id;
291  $rsql .= " AND pfd.fk_user_demande = u.rowid";
292  $rsql .= " AND pfd.traite = 0";
293  $rsql .= " ORDER BY pfd.date_demande DESC";
294 
295  $result_sql = $db->query($rsql);
296  if ($result_sql)
297  {
298  $numprlv = $db->num_rows($result_sql);
299  }
300 
301  if ($numprlv>0){
302  $error++;
303  setEventMessages($objecttmp->ref.' '.$langs->trans("RequestAlreadyDone"), $objecttmp->errors, 'warnings');
304  }
305  else if (!empty($objecttmp->mode_reglement_code ) && $objecttmp->mode_reglement_code != 'PRE'){
306  $error++;
307  setEventMessages($objecttmp->ref.' '.$langs->trans("BadPaymentMethod"), $objecttmp->errors, 'errors');
308  }
309  else {
310  $listofbills[] = $objecttmp; // $listofbills will only contains invoices with good payment method and no request already done
311  }
312  }
313  }
314 
315  //Massive withdraw request for request with no errors
316  if(!empty($listofbills))
317  {
318  $nbwithdrawrequestok=0;
319  foreach($listofbills as $aBill)
320  {
321  $db->begin();
322  $result = $aBill->demande_prelevement($user, $aBill->resteapayer);
323  if ($result > 0)
324  {
325  $db->commit();
326  $nbwithdrawrequestok++;
327  }
328  else
329  {
330 
331  $db->rollback();
332  setEventMessages($aBill->error, $aBill->errors, 'errors');
333  }
334  }
335  if ($nbwithdrawrequestok > 0)
336  {
337  setEventMessages($langs->trans("WithdrawRequestsDone", $nbwithdrawrequestok), null, 'mesgs');
338  }
339  }
340  }
341 }
342 
343 
344 
345 /*
346  * View
347  */
348 
349 $form = new Form($db);
350 $formother = new FormOther($db);
351 $formfile = new FormFile($db);
352 $bankaccountstatic=new Account($db);
353 $facturestatic=new Facture($db);
354 $formcompany=new FormCompany($db);
355 $thirdpartystatic=new Societe($db);
356 
357 // llxHeader('',$langs->trans('CustomersInvoices'),'EN:Customers_Invoices|FR:Factures_Clients|ES:Facturas_a_clientes');
358 
359 $sql = 'SELECT';
360 if ($sall || $search_product_category > 0) $sql = 'SELECT DISTINCT';
361 $sql.= ' f.rowid as id, f.facnumber as ref, f.ref_client, f.type, f.note_private, f.note_public, f.increment, f.fk_mode_reglement, f.total as total_ht, f.tva as total_vat, f.total_ttc,';
362 $sql.= ' f.localtax1 as total_localtax1, f.localtax2 as total_localtax2,';
363 $sql.= ' f.datef as df, f.date_lim_reglement as datelimite,';
364 $sql.= ' f.paye as paye, f.fk_statut,';
365 $sql.= ' f.datec as date_creation, f.tms as date_update,';
366 $sql.= ' s.rowid as socid, s.nom as name, s.email, s.town, s.zip, s.fk_pays, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta as code_compta_client, s.code_compta_fournisseur,';
367 $sql.= " typent.code as typent_code,";
368 $sql.= " state.code_departement as state_code, state.nom as state_name,";
369 $sql.= " country.code as country_code,";
370 $sql.= " p.rowid as project_id, p.ref as project_ref, p.title as project_label";
371 // We need dynamount_payed to be able to sort on status (value is surely wrong because we can count several lines several times due to other left join or link with contacts. But what we need is just 0 or > 0)
372 // TODO Better solution to be able to sort on already payed or remain to pay is to store amount_payed in a denormalized field.
373 if (! $sall) $sql.= ', SUM(pf.amount) as dynamount_payed';
374 if ($search_categ_cus) $sql .= ", cc.fk_categorie, cc.fk_soc";
375 
376 // Add fields from extrafields
377 foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : '');
378 // Add fields from hooks
379 $parameters=array();
380 $reshook=$hookmanager->executeHooks('printFieldListSelect',$parameters); // Note that $action and $object may have been modified by hook
381 $sql.=$hookmanager->resPrint;
382 $sql.= ' FROM '.MAIN_DB_PREFIX.'societe as s';
383 $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays)";
384 $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typent)";
385 $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)";
386 if (! empty($search_categ_cus)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_societe as cc ON s.rowid = cc.fk_soc"; // We'll need this table joined to the select in order to filter by categ
387 
388 $sql.= ', '.MAIN_DB_PREFIX.'facture as f';
389 if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture_extrafields as ef on (f.rowid = ef.fk_object)";
390 if (! $sall) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiement_facture as pf ON pf.fk_facture = f.rowid';
391 if ($sall || $search_product_category > 0) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'facturedet as pd ON f.rowid=pd.fk_facture';
392 if ($search_product_category > 0) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product=pd.fk_product';
393 $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = f.fk_projet";
394 // We'll need this table joined to the select in order to filter by sale
395 if ($search_sale > 0 || (! $user->rights->societe->client->voir && ! $socid)) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
396 if ($search_user > 0)
397 {
398  $sql.=", ".MAIN_DB_PREFIX."element_contact as ec";
399  $sql.=", ".MAIN_DB_PREFIX."c_type_contact as tc";
400 }
401 $sql.= ' WHERE f.fk_soc = s.rowid';
402 $sql.= ' AND f.entity IN ('.getEntity('facture').')';
403 if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
404 if ($search_product_category > 0) $sql.=" AND cp.fk_categorie = ".$db->escape($search_product_category);
405 if ($socid > 0) $sql.= ' AND s.rowid = '.$socid;
406 if ($userid)
407 {
408  if ($userid == -1) $sql.=' AND f.fk_user_author IS NULL';
409  else $sql.=' AND f.fk_user_author = '.$userid;
410 }
411 if ($filtre)
412 {
413  $aFilter = explode(',', $filtre);
414  foreach ($aFilter as $filter)
415  {
416  $filt = explode(':', $filter);
417  $sql .= ' AND ' . $db->escape(trim($filt[0])) . ' = ' . $db->escape(trim($filt[1]));
418  }
419 }
420 if ($search_ref) $sql .= natural_search('f.facnumber', $search_ref);
421 if ($search_refcustomer) $sql .= natural_search('f.ref_client', $search_refcustomer);
422 if ($search_type != '' && $search_type != '-1') $sql.=" AND f.type IN (".$db->escape($search_type).")";
423 if ($search_project) $sql .= natural_search('p.ref', $search_project);
424 if ($search_societe) $sql .= natural_search('s.nom', $search_societe);
425 if ($search_town) $sql.= natural_search('s.town', $search_town);
426 if ($search_zip) $sql.= natural_search("s.zip",$search_zip);
427 if ($search_state) $sql.= natural_search("state.nom",$search_state);
428 if ($search_country) $sql .= " AND s.fk_pays IN (".$db->escape($search_country).')';
429 if ($search_type_thirdparty) $sql .= " AND s.fk_typent IN (".$db->escape($search_type_thirdparty).')';
430 if ($search_company) $sql .= natural_search('s.nom', $search_company);
431 if ($search_montant_ht != '') $sql.= natural_search('f.total', $search_montant_ht, 1);
432 if ($search_montant_vat != '') $sql.= natural_search('f.tva', $search_montant_vat, 1);
433 if ($search_montant_localtax1 != '') $sql.= natural_search('f.localtax1', $search_montant_localtax1, 1);
434 if ($search_montant_localtax2 != '') $sql.= natural_search('f.localtax2', $search_montant_localtax2, 1);
435 if ($search_montant_ttc != '') $sql.= natural_search('f.total_ttc', $search_montant_ttc, 1);
436 if ($search_categ_cus > 0) $sql.= " AND cc.fk_categorie = ".$db->escape($search_categ_cus);
437 if ($search_categ_cus == -2) $sql.= " AND cc.fk_categorie IS NULL";
438 if ($search_status != '-1' && $search_status != '')
439 {
440  if (is_numeric($search_status) && $search_status >= 0)
441  {
442  if ($search_status == '0') $sql.=" AND f.fk_statut = 0"; // draft
443  if ($search_status == '1') $sql.=" AND f.fk_statut = 1"; // unpayed
444  if ($search_status == '2') $sql.=" AND f.fk_statut = 2"; // payed Not that some corrupted data may contains f.fk_statut = 1 AND f.paye = 1 (it means payed too but should not happend. If yes, reopen and reclassify billed)
445  if ($search_status == '3') $sql.=" AND f.fk_statut = 3"; // abandonned
446  }
447  else
448  {
449  $sql.= " AND f.fk_statut IN (".$search_status.")"; // When search_status is '1,2' for example
450  }
451 }
452 if ($search_paymentmode > 0) $sql .= " AND f.fk_mode_reglement = ".$db->escape($search_paymentmode);
453 if ($search_month > 0)
454 {
455  if ($search_year > 0 && empty($search_day))
456  $sql.= " AND f.datef BETWEEN '".$db->idate(dol_get_first_day($search_year,$search_month,false))."' AND '".$db->idate(dol_get_last_day($search_year,$search_month,false))."'";
457  else if ($search_year > 0 && ! empty($search_day))
458  $sql.= " AND f.datef BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $search_month, $search_day, $search_year))."' AND '".$db->idate(dol_mktime(23, 59, 59, $search_month, $search_day, $search_year))."'";
459  else
460  $sql.= " AND date_format(f.datef, '%m') = '".$search_month."'";
461 }
462 else if ($search_year > 0)
463 {
464  $sql.= " AND f.datef BETWEEN '".$db->idate(dol_get_first_day($search_year,1,false))."' AND '".$db->idate(dol_get_last_day($search_year,12,false))."'";
465 }
466 if ($search_month_lim > 0)
467 {
468  if ($search_year_lim > 0 && empty($search_day_lim))
469  $sql.= " AND f.date_lim_reglement BETWEEN '".$db->idate(dol_get_first_day($search_year_lim,$search_month_lim,false))."' AND '".$db->idate(dol_get_last_day($search_year_lim,$search_month_lim,false))."'";
470  else if ($search_year_lim > 0 && ! empty($search_day_lim))
471  $sql.= " AND f.date_lim_reglement BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $search_month_lim, $search_day_lim, $search_year_lim))."' AND '".$db->idate(dol_mktime(23, 59, 59, $search_month_lim, $search_day_lim, $search_year_lim))."'";
472  else
473  $sql.= " AND date_format(f.date_lim_reglement, '%m') = '".$db->escape($search_month_lim)."'";
474 }
475 else if ($search_year_lim > 0)
476 {
477  $sql.= " AND f.date_lim_reglement BETWEEN '".$db->idate(dol_get_first_day($search_year_lim,1,false))."' AND '".$db->idate(dol_get_last_day($search_year_lim,12,false))."'";
478 }
479 if ($option == 'late') $sql.=" AND f.date_lim_reglement < '".$db->idate(dol_now() - $conf->facture->client->warning_delay)."'";
480 if ($search_sale > 0) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$search_sale;
481 if ($search_user > 0)
482 {
483  $sql.= " AND ec.fk_c_type_contact = tc.rowid AND tc.element='facture' AND tc.source='internal' AND ec.element_id = f.rowid AND ec.fk_socpeople = ".$search_user;
484 }
485 // Add where from extra fields
486 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
487 // Add where from hooks
488 $parameters=array();
489 $reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters); // Note that $action and $object may have been modified by hook
490 $sql.=$hookmanager->resPrint;
491 
492 if (! $sall)
493 {
494  $sql.= ' GROUP BY f.rowid, f.facnumber, ref_client, f.type, f.note_private, f.note_public, f.increment, f.fk_mode_reglement, f.total, f.tva, f.total_ttc,';
495  $sql.= ' f.localtax1, f.localtax2,';
496  $sql.= ' f.datef, f.date_lim_reglement,';
497  $sql.= ' f.paye, f.fk_statut,';
498  $sql.= ' f.datec, f.tms,';
499  $sql.= ' s.rowid, s.nom, s.email, s.town, s.zip, s.fk_pays, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,';
500  $sql.= ' typent.code,';
501  $sql.= ' state.code_departement, state.nom,';
502  $sql.= ' country.code,';
503  $sql.= " p.rowid, p.ref, p.title";
504  if ($search_categ_cus) $sql .= ", cc.fk_categorie, cc.fk_soc";
505  // Add fields from extrafields
506  foreach ($extrafields->attribute_label as $key => $val) //prevent error with sql_mode=only_full_group_by
507  {
508  $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key : '');
509  }
510 }
511 else
512 {
513  $sql .= natural_search(array_keys($fieldstosearchall), $sall);
514 }
515 
516 $sql.= ' ORDER BY ';
517 $listfield=explode(',',$sortfield);
518 $listorder=explode(',',$sortorder);
519 foreach ($listfield as $key => $value) $sql.= $listfield[$key].' '.($listorder[$key]?$listorder[$key]:'DESC').',';
520 $sql.= ' f.rowid DESC ';
521 
522 $nbtotalofrecords = '';
523 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
524 {
525  $result = $db->query($sql);
526  $nbtotalofrecords = $db->num_rows($result);
527  if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0
528  {
529  $page = 0;
530  $offset = 0;
531  }
532 }
533 
534 $sql.= $db->plimit($limit+1,$offset);
535 
536 $resql = $db->query($sql);
537 
538 if ($resql)
539 {
540  $num = $db->num_rows($resql);
541 
542  $arrayofselected=is_array($toselect)?$toselect:array();
543 
544  if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $sall)
545  {
546  $obj = $db->fetch_object($resql);
547  $id = $obj->id;
548 
549  header("Location: ".DOL_URL_ROOT.'/compta/facture/card.php?facid='.$id);
550  exit;
551  }
552 
553  llxHeader('',$langs->trans('CustomersInvoices'),'EN:Customers_Invoices|FR:Factures_Clients|ES:Facturas_a_clientes');
554 
555  if ($socid)
556  {
557  $soc = new Societe($db);
558  $soc->fetch($socid);
559  if (empty($search_societe)) $search_societe = $soc->name;
560  }
561 
562  $param='&socid='.$socid;
563  if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage);
564  if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit);
565  if ($sall) $param.='&sall='.urlencode($sall);
566  if ($search_day) $param.='&search_day='.urlencode($search_day);
567  if ($search_month) $param.='&search_month='.urlencode($search_month);
568  if ($search_year) $param.='&search_year=' .urlencode($search_year);
569  if ($search_day_lim) $param.='&search_day_lim='.urlencode($search_day_lim);
570  if ($search_month_lim) $param.='&search_month_lim='.urlencode($search_month_lim);
571  if ($search_year_lim) $param.='&search_year_lim=' .urlencode($search_year_lim);
572  if ($search_ref) $param.='&search_ref=' .urlencode($search_ref);
573  if ($search_refcustomer) $param.='&search_refcustomer=' .urlencode($search_refcustomer);
574  if ($search_type != '') $param.='&search_type='.urlencode($search_type);
575  if ($search_societe) $param.='&search_societe=' .urlencode($search_societe);
576  if ($search_town) $param.='&search_town='.urlencode($search_town);
577  if ($search_zip) $param.='&search_zip='.urlencode($search_zip);
578  if ($search_sale > 0) $param.='&search_sale=' .urlencode($search_sale);
579  if ($search_user > 0) $param.='&search_user=' .urlencode($search_user);
580  if ($search_product_category > 0) $param.='&search_product_category=' .urlencode($search_product_category);
581  if ($search_montant_ht != '') $param.='&search_montant_ht='.urlencode($search_montant_ht);
582  if ($search_montant_vat != '') $param.='&search_montant_vat='.urlencode($search_montant_vat);
583  if ($search_montant_localtax1 != '') $param.='&search_montant_localtax1='.urlencode($search_montant_localtax1);
584  if ($search_montant_localtax2 != '') $param.='&search_montant_localtax2='.urlencode($search_montant_localtax2);
585  if ($search_montant_ttc != '') $param.='&search_montant_ttc='.urlencode($search_montant_ttc);
586  if ($search_status != '') $param.='&search_status='.urlencode($search_status);
587  if ($search_paymentmode > 0) $param.='&search_paymentmode='.urlencode($search_paymentmode);
588  if ($show_files) $param.='&show_files='.urlencode($show_files);
589  if ($option) $param.="&search_option=".urlencode($option);
590  if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss);
591  if ($search_categ_cus > 0) $param.='&search_categ_cus='.urlencode($search_categ_cus);
592 
593  // Add $param from extra fields
594  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
595 
596  $arrayofmassactions=array(
597  'validate'=>$langs->trans("Validate"),
598  'presend'=>$langs->trans("SendByMail"),
599  'builddoc'=>$langs->trans("PDFMerge"),
600  );
601  if ($conf->prelevement->enabled) {
602  $langs->load("withdrawals");
603  $arrayofmassactions['withdrawrequest'] = $langs->trans("MakeWithdrawRequest");
604  }
605  if ($user->rights->facture->supprimer) {
606  if (!empty($conf->global->INVOICE_CAN_REMOVE_DRAFT_ONLY)) {
607  $arrayofmassactions['predeletedraft'] = $langs->trans("Deletedraft");
608  }
609  elseif (!empty($conf->global->INVOICE_CAN_ALWAYS_BE_REMOVED)) { // mass deletion never possible on invoices on such situation
610  $arrayofmassactions['predelete'] = $langs->trans("Delete");
611  }
612  }
613  if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array();
614  $massactionbutton=$form->selectMassAction('', $arrayofmassactions);
615 
616  $newcardbutton='';
617  if($user->rights->facture->creer)
618  {
619  $newcardbutton='<a class="butActionNew" href="'.DOL_URL_ROOT.'/compta/facture/card.php?action=create"><span class="valignmiddle">'.$langs->trans('NewBill').'</span>';
620  $newcardbutton.= '<span class="fa fa-plus-circle valignmiddle"></span>';
621  $newcardbutton.= '</a>';
622  }
623 
624  $i = 0;
625  print '<form method="POST" name="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n";
626 
627  if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
628  print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
629  print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
630  print '<input type="hidden" name="action" value="list">';
631  print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
632  print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
633  print '<input type="hidden" name="page" value="'.$page.'">';
634  print '<input type="hidden" name="viewstatut" value="'.$viewstatut.'">';
635  print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
636 
637  print_barre_liste($langs->trans('BillsCustomers').' '.($socid?' '.$soc->name:''), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_accountancy.png', 0, $newcardbutton, '', $limit);
638 
639  $topicmail="SendBillRef";
640  $modelmail="facture_send";
641  $objecttmp=new Facture($db);
642  $trackid='inv'.$object->id;
643  include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
644 
645  if ($sall)
646  {
647  foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val);
648  print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall) . join(', ',$fieldstosearchall).'</div>';
649  }
650 
651  // If the user can view prospects other than his'
652  $moreforfilter='';
653  if ($user->rights->societe->client->voir || $socid)
654  {
655  $langs->load("commercial");
656  $moreforfilter.='<div class="divsearchfield">';
657  $moreforfilter.=$langs->trans('ThirdPartiesOfSaleRepresentative'). ': ';
658  $moreforfilter.=$formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, 1, 'maxwidth200');
659  $moreforfilter.='</div>';
660  }
661  // If the user can view prospects other than his'
662  if ($user->rights->societe->client->voir || $socid)
663  {
664  $moreforfilter.='<div class="divsearchfield">';
665  $moreforfilter.=$langs->trans('LinkedToSpecificUsers'). ': ';
666  $moreforfilter.=$form->select_dolusers($search_user, 'search_user', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth200');
667  $moreforfilter.='</div>';
668  }
669  // If the user can view prospects other than his'
670  if ($conf->categorie->enabled && ($user->rights->produit->lire || $user->rights->service->lire))
671  {
672  include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
673  $moreforfilter.='<div class="divsearchfield">';
674  $moreforfilter.=$langs->trans('IncludingProductWithTag'). ': ';
675  $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, null, 'parent', null, null, 1);
676  $moreforfilter.=$form->selectarray('search_product_category', $cate_arbo, $search_product_category, 1, 0, 0, '', 0, 0, 0, 0, 'maxwidth300', 1);
677  $moreforfilter.='</div>';
678  }
679  if (! empty($conf->categorie->enabled))
680  {
681  require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php';
682  $moreforfilter.='<div class="divsearchfield">';
683  $moreforfilter.=$langs->trans('CustomersProspectsCategoriesShort').': ';
684  $moreforfilter.=$formother->select_categories('customer',$search_categ_cus,'search_categ_cus',1);
685  $moreforfilter.='</div>';
686  }
687  $parameters=array();
688  $reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook
689  if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint;
690  else $moreforfilter = $hookmanager->resPrint;
691 
692  if ($moreforfilter)
693  {
694  print '<div class="liste_titre liste_titre_bydiv centpercent">';
695  print $moreforfilter;
696  print '</div>';
697  }
698 
699  $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage;
700  $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
701  if ($massactionbutton) $selectedfields.=$form->showCheckAddButtons('checkforselect', 1);
702 
703  print '<div class="div-table-responsive">';
704  print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
705 
706  // Filters lines
707  print '<tr class="liste_titre_filter">';
708  // Ref
709  if (! empty($arrayfields['f.facnumber']['checked']))
710  {
711  print '<td class="liste_titre" align="left">';
712  print '<input class="flat" size="6" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
713  print '</td>';
714  }
715  // Ref customer
716  if (! empty($arrayfields['f.ref_client']['checked']))
717  {
718  print '<td class="liste_titre">';
719  print '<input class="flat" size="6" type="text" name="search_refcustomer" value="'.dol_escape_htmltag($search_refcustomer).'">';
720  print '</td>';
721  }
722  // Type
723  if (! empty($arrayfields['f.type']['checked']))
724  {
725  print '<td class="liste_titre maxwidthonsmartphone">';
726  $listtype=array(
727  Facture::TYPE_STANDARD=>$langs->trans("InvoiceStandard"),
728  Facture::TYPE_REPLACEMENT=>$langs->trans("InvoiceReplacement"),
729  Facture::TYPE_CREDIT_NOTE=>$langs->trans("InvoiceAvoir"),
730  Facture::TYPE_DEPOSIT=>$langs->trans("InvoiceDeposit"),
731  );
732  if (! empty($conf->global->INVOICE_USE_SITUATION))
733  {
734  $listtype[Facture::TYPE_SITUATION] = $langs->trans("InvoiceSituation");
735  }
736  //$listtype[Facture::TYPE_PROFORMA]=$langs->trans("InvoiceProForma"); // A proformat invoice is not an invoice but must be an order.
737  print $form->selectarray('search_type', $listtype, $search_type, 1, 0, 0, '', 0, 0, 0, 'ASC', 'maxwidth100');
738  print '</td>';
739  }
740  // Date invoice
741  if (! empty($arrayfields['f.date']['checked']))
742  {
743  print '<td class="liste_titre nowraponall" align="center">';
744  if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="search_day" value="'.dol_escape_htmltag($search_day).'">';
745  print '<input class="flat valignmiddle width25" type="text" size="1" maxlength="2" name="search_month" value="'.dol_escape_htmltag($search_month).'">';
746  $formother->select_year($search_year?$search_year:-1,'search_year',1, 20, 5, 0, 0, '', 'widthauto valignmiddle');
747  print '</td>';
748  }
749  // Date due
750  if (! empty($arrayfields['f.date_lim_reglement']['checked']))
751  {
752  print '<td class="liste_titre nowraponall" align="center">';
753  if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="search_day_lim" value="'.dol_escape_htmltag($search_day_lim).'">';
754  print '<input class="flat valignmiddle width25" type="text" size="1" maxlength="2" name="search_month_lim" value="'.dol_escape_htmltag($search_month_lim).'">';
755  $formother->select_year($search_year_lim?$search_year_lim:-1,'search_year_lim',1, 20, 5, 0, 0, '', 'widthauto valignmiddle');
756  print '<br><input type="checkbox" name="search_option" value="late"'.($option == 'late'?' checked':'').'> '.$langs->trans("Alert");
757  print '</td>';
758  }
759  // Project
760  if (! empty($arrayfields['p.ref']['checked']))
761  {
762  print '<td class="liste_titre"><input class="flat" type="text" size="6" name="search_project" value="'.$search_project.'"></td>';
763  }
764  // Thirpdarty
765  if (! empty($arrayfields['s.nom']['checked']))
766  {
767  print '<td class="liste_titre"><input class="flat" type="text" size="6" name="search_societe" value="'.$search_societe.'"></td>';
768  }
769  // Town
770  if (! empty($arrayfields['s.town']['checked'])) print '<td class="liste_titre"><input class="flat" type="text" size="6" name="search_town" value="'.dol_escape_htmltag($search_town).'"></td>';
771  // Zip
772  if (! empty($arrayfields['s.zip']['checked'])) print '<td class="liste_titre"><input class="flat" type="text" size="4" name="search_zip" value="'.dol_escape_htmltag($search_zip).'"></td>';
773  // State
774  if (! empty($arrayfields['state.nom']['checked']))
775  {
776  print '<td class="liste_titre">';
777  print '<input class="flat" size="4" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).'">';
778  print '</td>';
779  }
780  // Country
781  if (! empty($arrayfields['country.code_iso']['checked']))
782  {
783  print '<td class="liste_titre" align="center">';
784  print $form->select_country($search_country,'search_country','',0,'maxwidth100');
785  print '</td>';
786  }
787  // Company type
788  if (! empty($arrayfields['typent.code']['checked']))
789  {
790  print '<td class="liste_titre maxwidthonsmartphone" align="center">';
791  print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 0, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT)?'ASC':$conf->global->SOCIETE_SORT_ON_TYPEENT), 'maxwidth100');
792  print '</td>';
793  }
794  // Payment mode
795  if (! empty($arrayfields['f.fk_mode_reglement']['checked']))
796  {
797  print '<td class="liste_titre" align="left">';
798  $form->select_types_paiements($search_paymentmode, 'search_paymentmode', '', 0, 1, 1, 10);
799  print '</td>';
800  }
801  if (! empty($arrayfields['f.total_ht']['checked']))
802  {
803  // Amount
804  print '<td class="liste_titre" align="right">';
805  print '<input class="flat" type="text" size="5" name="search_montant_ht" value="'.dol_escape_htmltag($search_montant_ht).'">';
806  print '</td>';
807  }
808  if (! empty($arrayfields['f.total_vat']['checked']))
809  {
810  // Amount
811  print '<td class="liste_titre" align="right">';
812  print '<input class="flat" type="text" size="5" name="search_montant_vat" value="'.dol_escape_htmltag($search_montant_vat).'">';
813  print '</td>';
814  }
815  if (! empty($arrayfields['f.total_localtax1']['checked']))
816  {
817  // Localtax1
818  print '<td class="liste_titre" align="right">';
819  print '<input class="flat" type="text" size="5" name="search_montant_localtax1" value="'.$search_montant_localtax1.'">';
820  print '</td>';
821  }
822  if (! empty($arrayfields['f.total_localtax2']['checked']))
823  {
824  // Localtax2
825  print '<td class="liste_titre" align="right">';
826  print '<input class="flat" type="text" size="5" name="search_montant_localtax2" value="'.$search_montant_localtax2.'">';
827  print '</td>';
828  }
829  if (! empty($arrayfields['f.total_ttc']['checked']))
830  {
831  // Amount
832  print '<td class="liste_titre" align="right">';
833  print '<input class="flat" type="text" size="5" name="search_montant_ttc" value="'.dol_escape_htmltag($search_montant_ttc).'">';
834  print '</td>';
835  }
836  if (! empty($arrayfields['dynamount_payed']['checked']))
837  {
838  print '<td class="liste_titre" align="right">';
839  print '</td>';
840  }
841  if (! empty($arrayfields['rtp']['checked']))
842  {
843  print '<td class="liste_titre" align="right">';
844  print '</td>';
845  }
846  // Extra fields
847  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
848 
849  // Fields from hook
850  $parameters=array('arrayfields'=>$arrayfields);
851  $reshook=$hookmanager->executeHooks('printFieldListOption',$parameters); // Note that $action and $object may have been modified by hook
852  print $hookmanager->resPrint;
853  // Date creation
854  if (! empty($arrayfields['f.datec']['checked']))
855  {
856  print '<td class="liste_titre">';
857  print '</td>';
858  }
859  // Date modification
860  if (! empty($arrayfields['f.tms']['checked']))
861  {
862  print '<td class="liste_titre">';
863  print '</td>';
864  }
865  // Status
866  if (! empty($arrayfields['f.fk_statut']['checked']))
867  {
868  print '<td class="liste_titre maxwidthonsmartphone" align="right">';
869  $liststatus=array('0'=>$langs->trans("BillShortStatusDraft"), '1'=>$langs->trans("BillShortStatusNotPaid"), '2'=>$langs->trans("BillShortStatusPaid"), '1,2'=>$langs->trans("BillShortStatusNotPaid").'+'.$langs->trans("BillShortStatusPaid"), '3'=>$langs->trans("BillShortStatusCanceled"));
870  print $form->selectarray('search_status', $liststatus, $search_status, 1);
871  print '</td>';
872  }
873  // Action column
874  print '<td class="liste_titre" align="middle">';
875  $searchpicto=$form->showFilterButtons();
876  print $searchpicto;
877  print '</td>';
878  print "</tr>\n";
879 
880  print '<tr class="liste_titre">';
881  if (! empty($arrayfields['f.facnumber']['checked'])) print_liste_field_titre($arrayfields['f.facnumber']['label'],$_SERVER['PHP_SELF'],'f.facnumber','',$param,'',$sortfield,$sortorder);
882  if (! empty($arrayfields['f.ref_client']['checked'])) print_liste_field_titre($arrayfields['f.ref_client']['label'],$_SERVER["PHP_SELF"],'f.ref_client','',$param,'',$sortfield,$sortorder);
883  if (! empty($arrayfields['f.type']['checked'])) print_liste_field_titre($arrayfields['f.type']['label'],$_SERVER["PHP_SELF"],'f.type','',$param,'',$sortfield,$sortorder);
884  if (! empty($arrayfields['f.date']['checked'])) print_liste_field_titre($arrayfields['f.date']['label'],$_SERVER['PHP_SELF'],'f.datef','',$param,'align="center"',$sortfield,$sortorder);
885  if (! empty($arrayfields['f.date_lim_reglement']['checked'])) print_liste_field_titre($arrayfields['f.date_lim_reglement']['label'],$_SERVER['PHP_SELF'],"f.date_lim_reglement",'',$param,'align="center"',$sortfield,$sortorder);
886  if (! empty($arrayfields['p.ref']['checked'])) print_liste_field_titre($arrayfields['p.ref']['label'],$_SERVER['PHP_SELF'],"p.ref",'',$param,'',$sortfield,$sortorder);
887  if (! empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'],$_SERVER['PHP_SELF'],'s.nom','',$param,'',$sortfield,$sortorder);
888  if (! empty($arrayfields['s.town']['checked'])) print_liste_field_titre($arrayfields['s.town']['label'],$_SERVER["PHP_SELF"],'s.town','',$param,'',$sortfield,$sortorder);
889  if (! empty($arrayfields['s.zip']['checked'])) print_liste_field_titre($arrayfields['s.zip']['label'],$_SERVER["PHP_SELF"],'s.zip','',$param,'',$sortfield,$sortorder);
890  if (! empty($arrayfields['state.nom']['checked'])) print_liste_field_titre($arrayfields['state.nom']['label'],$_SERVER["PHP_SELF"],"state.nom","",$param,'',$sortfield,$sortorder);
891  if (! empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($arrayfields['country.code_iso']['label'],$_SERVER["PHP_SELF"],"country.code_iso","",$param,'align="center"',$sortfield,$sortorder);
892  if (! empty($arrayfields['typent.code']['checked'])) print_liste_field_titre($arrayfields['typent.code']['label'],$_SERVER["PHP_SELF"],"typent.code","",$param,'align="center"',$sortfield,$sortorder);
893  if (! empty($arrayfields['f.fk_mode_reglement']['checked'])) print_liste_field_titre($arrayfields['f.fk_mode_reglement']['label'],$_SERVER["PHP_SELF"],"f.fk_mode_reglement","",$param,"",$sortfield,$sortorder);
894  if (! empty($arrayfields['f.total_ht']['checked'])) print_liste_field_titre($arrayfields['f.total_ht']['label'],$_SERVER['PHP_SELF'],'f.total','',$param,'align="right"',$sortfield,$sortorder);
895  if (! empty($arrayfields['f.total_vat']['checked'])) print_liste_field_titre($arrayfields['f.total_vat']['label'],$_SERVER['PHP_SELF'],'f.tva','',$param,'align="right"',$sortfield,$sortorder);
896  if (! empty($arrayfields['f.total_localtax1']['checked'])) print_liste_field_titre($arrayfields['f.total_localtax1']['label'],$_SERVER['PHP_SELF'],'f.localtax1','',$param,'align="right"',$sortfield,$sortorder);
897  if (! empty($arrayfields['f.total_localtax2']['checked'])) print_liste_field_titre($arrayfields['f.total_localtax2']['label'],$_SERVER['PHP_SELF'],'f.localtax2','',$param,'align="right"',$sortfield,$sortorder);
898  if (! empty($arrayfields['f.total_ttc']['checked'])) print_liste_field_titre($arrayfields['f.total_ttc']['label'],$_SERVER['PHP_SELF'],'f.total_ttc','',$param,'align="right"',$sortfield,$sortorder);
899  if (! empty($arrayfields['dynamount_payed']['checked'])) print_liste_field_titre($arrayfields['dynamount_payed']['label'],$_SERVER['PHP_SELF'],'','',$param,'align="right"',$sortfield,$sortorder);
900  if (! empty($arrayfields['rtp']['checked'])) print_liste_field_titre($arrayfields['rtp']['label'],$_SERVER['PHP_SELF'],'','',$param,'align="right"',$sortfield,$sortorder);
901  // Extra fields
902  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
903  // Hook fields
904  $parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder);
905  $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook
906  print $hookmanager->resPrint;
907  if (! empty($arrayfields['f.datec']['checked'])) print_liste_field_titre($arrayfields['f.datec']['label'],$_SERVER["PHP_SELF"],"f.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder);
908  if (! empty($arrayfields['f.tms']['checked'])) print_liste_field_titre($arrayfields['f.tms']['label'],$_SERVER["PHP_SELF"],"f.tms","",$param,'align="center" class="nowrap"',$sortfield,$sortorder);
909  if (! empty($arrayfields['f.fk_statut']['checked'])) print_liste_field_titre($arrayfields['f.fk_statut']['label'],$_SERVER["PHP_SELF"],"f.fk_statut,f.paye,f.type,dynamount_payed","",$param,'align="right"',$sortfield,$sortorder);
910  print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch ');
911  print "</tr>\n";
912 
913  $projectstatic=new Project($db);
914  $discount = new DiscountAbsolute($db);
915 
916  if ($num > 0)
917  {
918  $i=0;
919  $totalarray=array();
920  while ($i < min($num,$limit))
921  {
922  $obj = $db->fetch_object($resql);
923 
924  $datelimit=$db->jdate($obj->datelimite);
925 
926  $facturestatic->id=$obj->id;
927  $facturestatic->ref=$obj->ref;
928  $facturestatic->type=$obj->type;
929  $facturestatic->total_ht=$obj->total_ht;
930  $facturestatic->total_tva=$obj->total_vat;
931  $facturestatic->total_ttc=$obj->total_ttc;
932  $facturestatic->statut=$obj->fk_statut;
933  $facturestatic->total_ttc=$obj->total_ttc;
934  $facturestatic->paye=$obj->paye;
935  $facturestatic->fk_soc=$obj->fk_soc;
936  $facturestatic->date_lim_reglement=$db->jdate($obj->datelimite);
937  $facturestatic->note_public=$obj->note_public;
938  $facturestatic->note_private=$obj->note_private;
939 
940  $thirdpartystatic->id=$obj->socid;
941  $thirdpartystatic->name=$obj->name;
942  $thirdpartystatic->client=$obj->client;
943  $thirdpartystatic->fournisseur=$obj->fournisseur;
944  $thirdpartystatic->code_client=$obj->code_client;
945  $thirdpartystatic->code_compta_client=$obj->code_compta_client;
946  $thirdpartystatic->code_fournisseur=$obj->code_fournisseur;
947  $thirdpartystatic->code_compta_fournisseur=$obj->code_compta_fournisseur;
948  $thirdpartystatic->email=$obj->email;
949  $thirdpartystatic->country_code=$obj->country_code;
950 
951  $paiement = $facturestatic->getSommePaiement();
952  $totalcreditnotes = $facturestatic->getSumCreditNotesUsed();
953  $totaldeposits = $facturestatic->getSumDepositsUsed();
954  $totalpay = $paiement + $totalcreditnotes + $totaldeposits;
955  $remaintopay = $facturestatic->total_ttc - $totalpay;
956  if ($facturestatic->type == Facture::TYPE_CREDIT_NOTE && $obj->paye == 1) {
957  $remaincreditnote = $discount->getAvailableDiscounts($obj->fk_soc, '', 'rc.fk_facture_source='.$facturestatic->id);
958  $remaintopay = -$remaincreditnote;
959  $totalpay = $facturestatic->total_ttc - $remaintopay;
960  }
961 
962  print '<tr class="oddeven">';
963  if (! empty($arrayfields['f.facnumber']['checked']))
964  {
965  print '<td class="nowrap">';
966 
967  print '<table class="nobordernopadding"><tr class="nocellnopadd">';
968 
969  print '<td class="nobordernopadding nowraponall">';
970  print $facturestatic->getNomUrl(1,'',200,0,'',0,1);
971  print empty($obj->increment)?'':' ('.$obj->increment.')';
972 
973  $filename=dol_sanitizeFileName($obj->ref);
974  $filedir=$conf->facture->dir_output . '/' . dol_sanitizeFileName($obj->ref);
975  $urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->id;
976  print $formfile->getDocumentsLink($facturestatic->element, $filename, $filedir);
977  print '</td>';
978  print '</tr>';
979  print '</table>';
980 
981  print "</td>\n";
982  if (! $i) $totalarray['nbfield']++;
983  }
984 
985  // Customer ref
986  if (! empty($arrayfields['f.ref_client']['checked']))
987  {
988  print '<td class="nowrap">';
989  print $obj->ref_client;
990  print '</td>';
991  if (! $i) $totalarray['nbfield']++;
992  }
993 
994  // Type
995  if (! empty($arrayfields['f.type']['checked']))
996  {
997  print '<td class="nowrap">';
998  print $facturestatic->getLibType();
999  print "</td>";
1000  if (! $i) $totalarray['nbfield']++;
1001  }
1002 
1003  // Date
1004  if (! empty($arrayfields['f.date']['checked']))
1005  {
1006  print '<td align="center" class="nowrap">';
1007  print dol_print_date($db->jdate($obj->df),'day');
1008  print '</td>';
1009  if (! $i) $totalarray['nbfield']++;
1010  }
1011 
1012  // Date limit
1013  if (! empty($arrayfields['f.date_lim_reglement']['checked']))
1014  {
1015  print '<td align="center" class="nowrap">'.dol_print_date($datelimit,'day');
1016  if ($facturestatic->hasDelay())
1017  {
1018  print img_warning($langs->trans('Alert').' - '.$langs->trans('Late'));
1019  }
1020  print '</td>';
1021  if (! $i) $totalarray['nbfield']++;
1022  }
1023 
1024  // Project
1025  if (! empty($arrayfields['p.ref']['checked']))
1026  {
1027  print '<td class="nowrap">';
1028  if ($obj->project_id > 0)
1029  {
1030  $projectstatic->id=$obj->project_id;
1031  $projectstatic->ref=$obj->project_ref;
1032  $projectstatic->title=$obj->project_label;
1033  print $projectstatic->getNomUrl(1);
1034  }
1035  print '</td>';
1036  if (! $i) $totalarray['nbfield']++;
1037  }
1038 
1039  // Third party
1040  if (! empty($arrayfields['s.nom']['checked']))
1041  {
1042  print '<td class="tdoverflowmax200">';
1043  print $thirdpartystatic->getNomUrl(1,'customer');
1044  print '</td>';
1045  if (! $i) $totalarray['nbfield']++;
1046  }
1047  // Town
1048  if (! empty($arrayfields['s.town']['checked']))
1049  {
1050  print '<td class="nocellnopadd">';
1051  print $obj->town;
1052  print '</td>';
1053  if (! $i) $totalarray['nbfield']++;
1054  }
1055  // Zip
1056  if (! empty($arrayfields['s.zip']['checked']))
1057  {
1058  print '<td class="nocellnopadd">';
1059  print $obj->zip;
1060  print '</td>';
1061  if (! $i) $totalarray['nbfield']++;
1062  }
1063  // State
1064  if (! empty($arrayfields['state.nom']['checked']))
1065  {
1066  print "<td>".$obj->state_name."</td>\n";
1067  if (! $i) $totalarray['nbfield']++;
1068  }
1069  // Country
1070  if (! empty($arrayfields['country.code_iso']['checked']))
1071  {
1072  print '<td align="center">';
1073  $tmparray=getCountry($obj->fk_pays,'all');
1074  print $tmparray['label'];
1075  print '</td>';
1076  if (! $i) $totalarray['nbfield']++;
1077  }
1078  // Type ent
1079  if (! empty($arrayfields['typent.code']['checked']))
1080  {
1081  print '<td align="center">';
1082  if (! is_array($typenArray) || count($typenArray)==0) $typenArray = $formcompany->typent_array(1);
1083  print $typenArray[$obj->typent_code];
1084  print '</td>';
1085  if (! $i) $totalarray['nbfield']++;
1086  }
1087  // Staff
1088  if (! empty($arrayfields['staff.code']['checked']))
1089  {
1090  print '<td align="center">';
1091  if (! is_array($staffArray) || count($staffArray)==0) $staffArray = $formcompany->effectif_array(1);
1092  print $staffArray[$obj->staff_code];
1093  print '</td>';
1094  if (! $i) $totalarray['nbfield']++;
1095  }
1096 
1097  // Payment mode
1098  if (! empty($arrayfields['f.fk_mode_reglement']['checked']))
1099  {
1100  print '<td>';
1101  $form->form_modes_reglement($_SERVER['PHP_SELF'], $obj->fk_mode_reglement, 'none', '', -1);
1102  print '</td>';
1103  if (! $i) $totalarray['nbfield']++;
1104  }
1105 
1106  // Amount HT
1107  if (! empty($arrayfields['f.total_ht']['checked']))
1108  {
1109  print '<td align="right">'.price($obj->total_ht)."</td>\n";
1110  if (! $i) $totalarray['nbfield']++;
1111  if (! $i) $totalarray['totalhtfield']=$totalarray['nbfield'];
1112  $totalarray['totalht'] += $obj->total_ht;
1113  }
1114  // Amount VAT
1115  if (! empty($arrayfields['f.total_vat']['checked']))
1116  {
1117  print '<td align="right">'.price($obj->total_vat)."</td>\n";
1118  if (! $i) $totalarray['nbfield']++;
1119  if (! $i) $totalarray['totalvatfield']=$totalarray['nbfield'];
1120  $totalarray['totalvat'] += $obj->total_vat;
1121  }
1122  // Amount LocalTax1
1123  if (! empty($arrayfields['f.total_localtax1']['checked']))
1124  {
1125  print '<td align="right">'.price($obj->total_localtax1)."</td>\n";
1126  if (! $i) $totalarray['nbfield']++;
1127  if (! $i) $totalarray['totallocaltax1field']=$totalarray['nbfield'];
1128  $totalarray['totallocaltax1'] += $obj->total_localtax1;
1129  }
1130  // Amount LocalTax2
1131  if (! empty($arrayfields['f.total_localtax2']['checked']))
1132  {
1133  print '<td align="right">'.price($obj->total_localtax2)."</td>\n";
1134  if (! $i) $totalarray['nbfield']++;
1135  if (! $i) $totalarray['totallocaltax2field']=$totalarray['nbfield'];
1136  $totalarray['totallocaltax2'] += $obj->total_localtax2;
1137  }
1138  // Amount TTC
1139  if (! empty($arrayfields['f.total_ttc']['checked']))
1140  {
1141  print '<td align="right">'.price($obj->total_ttc)."</td>\n";
1142  if (! $i) $totalarray['nbfield']++;
1143  if (! $i) $totalarray['totalttcfield']=$totalarray['nbfield'];
1144  $totalarray['totalttc'] += $obj->total_ttc;
1145  }
1146 
1147  if (! empty($arrayfields['dynamount_payed']['checked']))
1148  {
1149  print '<td align="right">'.(! empty($totalpay)?price($totalpay,0,$langs):'&nbsp;').'</td>'; // TODO Use a denormalized field
1150  if (! $i) $totalarray['nbfield']++;
1151  if (! $i) $totalarray['totalamfield']=$totalarray['nbfield'];
1152  $totalarray['totalam'] += $totalpay;
1153  }
1154 
1155  if (! empty($arrayfields['rtp']['checked']))
1156  {
1157  print '<td align="right">'.(! empty($remaintopay)?price($remaintopay,0,$langs):'&nbsp;').'</td>'; // TODO Use a denormalized field
1158  if (! $i) $totalarray['nbfield']++;
1159  if (! $i) $totalarray['totalrtpfield']=$totalarray['nbfield'];
1160  $totalarray['totalrtp'] += $remaintopay;
1161  }
1162 
1163  // Extra fields
1164  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
1165  // Fields from hook
1166  $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj);
1167  $reshook=$hookmanager->executeHooks('printFieldListValue',$parameters); // Note that $action and $object may have been modified by hook
1168  print $hookmanager->resPrint;
1169  // Date creation
1170  if (! empty($arrayfields['f.datec']['checked']))
1171  {
1172  print '<td align="center" class="nowrap">';
1173  print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser');
1174  print '</td>';
1175  if (! $i) $totalarray['nbfield']++;
1176  }
1177  // Date modification
1178  if (! empty($arrayfields['f.tms']['checked']))
1179  {
1180  print '<td align="center" class="nowrap">';
1181  print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser');
1182  print '</td>';
1183  if (! $i) $totalarray['nbfield']++;
1184  }
1185  // Status
1186  if (! empty($arrayfields['f.fk_statut']['checked']))
1187  {
1188  print '<td align="right" class="nowrap">';
1189  print $facturestatic->LibStatut($obj->paye,$obj->fk_statut,5,$paiement,$obj->type);
1190  print "</td>";
1191  if (! $i) $totalarray['nbfield']++;
1192  }
1193 
1194  // Action column
1195  print '<td class="nowrap" align="center">';
1196  if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
1197  {
1198  $selected=0;
1199  if (in_array($obj->id, $arrayofselected)) $selected=1;
1200  print '<input id="cb'.$obj->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->id.'"'.($selected?' checked="checked"':'').'>';
1201  }
1202  print '</td>' ;
1203  if (! $i) $totalarray['nbfield']++;
1204 
1205  print "</tr>\n";
1206 
1207  $i++;
1208  }
1209 
1210  // Show total line
1211  if (isset($totalarray['totalhtfield'])
1212  || isset($totalarray['totalvatfield'])
1213  || isset($totalarray['totallocaltax1field'])
1214  || isset($totalarray['totallocaltax2field'])
1215  || isset($totalarray['totalttcfield'])
1216  || isset($totalarray['totalamfield'])
1217  || isset($totalarray['totalrtpfield'])
1218  )
1219  {
1220  print '<tr class="liste_total">';
1221  $i=0;
1222  while ($i < $totalarray['nbfield'])
1223  {
1224  $i++;
1225  if ($i == 1)
1226  {
1227  if ($num < $limit && empty($offset)) print '<td align="left">'.$langs->trans("Total").'</td>';
1228  else print '<td align="left">'.$langs->trans("Totalforthispage").'</td>';
1229  }
1230  elseif ($totalarray['totalhtfield'] == $i) print '<td align="right">'.price($totalarray['totalht']).'</td>';
1231  elseif ($totalarray['totalvatfield'] == $i) print '<td align="right">'.price($totalarray['totalvat']).'</td>';
1232  elseif ($totalarray['totallocaltax1field'] == $i) print '<td align="right">'.price($totalarray['totallocaltax1']).'</td>';
1233  elseif ($totalarray['totallocaltax2field'] == $i) print '<td align="right">'.price($totalarray['totallocaltax2']).'</td>';
1234  elseif ($totalarray['totalttcfield'] == $i) print '<td align="right">'.price($totalarray['totalttc']).'</td>';
1235  elseif ($totalarray['totalamfield'] == $i) print '<td align="right">'.price($totalarray['totalam']).'</td>';
1236  elseif ($totalarray['totalrtpfield'] == $i) print '<td align="right">'.price($totalarray['totalrtp']).'</td>';
1237  else print '<td></td>';
1238  }
1239  print '</tr>';
1240  }
1241  }
1242 
1243  $db->free($resql);
1244 
1245  $parameters=array('arrayfields'=>$arrayfields, 'sql'=>$sql);
1246  $reshook=$hookmanager->executeHooks('printFieldListFooter',$parameters); // Note that $action and $object may have been modified by hook
1247  print $hookmanager->resPrint;
1248 
1249  print "</table>\n";
1250  print '</div>';
1251 
1252  print "</form>\n";
1253 
1254  $hidegeneratedfilelistifempty=1;
1255  if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty=0;
1256 
1257  // Show list of available documents
1258  $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
1259  $urlsource.=str_replace('&amp;','&',$param);
1260 
1261  $filedir=$diroutputmassaction;
1262  $genallowed=$user->rights->facture->lire;
1263  $delallowed=$user->rights->facture->creer;
1264 
1265  print $formfile->showdocuments('massfilesarea_invoices','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,'','','',null,$hidegeneratedfilelistifempty);
1266 }
1267 else
1268 {
1269  dol_print_error($db);
1270 }
1271 
1272 // End of page
1273 llxFooter();
1274 $db->close();
img_warning($titlealt='default', $moreatt='')
Show warning logo.
llxFooter()
Empty footer.
Definition: wrapper.php:56
GETPOST($paramname, $check='none', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
const TYPE_STANDARD
Standard invoice.
print
Draft customers invoices.
Definition: index.php:91
setEventMessages($mesg, $mesgs, $style='mesgs')
Set event messages in dol_events session object.
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:1053
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm=false, $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
const TYPE_REPLACEMENT
Replacement invoice.
dol_get_first_day($year, $month=1, $gm=false)
Return GMT time for first day of a month or year.
Definition: date.lib.php:453
dol_print_error($db='', $error='', $errors=null)
Affiche message erreur system avec toutes les informations pour faciliter le diagnostic et la remonte...
getCountry($searchkey, $withcode='', $dbtouse=0, $outputlangs='', $entconv=1, $searchlabel='')
Return country label, code or id from an id, code or label.
const TYPE_SITUATION
Situation invoice.
Class to manage bank accounts.
const TYPE_CREDIT_NOTE
Credit note invoice.
Class to build HTML component for third parties management Only common components are here...
Class to manage standard extra fields.
Class to manage generation of HTML components Only common components must be here.
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...)
Class to manage projects.
const STATUS_DRAFT
Draft status.
Classe permettant la generation de composants html autre Only common components are here...
llxHeader()
Empty header.
Definition: wrapper.php:44
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_now($mode='gmt')
Return date for now.
Class to offer components to list and upload files.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages...
dol_print_date($time, $format='', $tzoutput='tzserver', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
const TYPE_DEPOSIT
Deposit invoice.
dol_get_last_day($year, $month=12, $gm=false)
Return GMT time for last day of a month or year.
Definition: date.lib.php:467
restrictedArea($user, $features, $objectid=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0)
Check permissions of a user to show a page and an object.
Class to manage absolute discounts.
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="")
Show title line of an array.
Class to manage invoices.
price2num($amount, $rounding='', $alreadysqlnb=0)
Function that return a number with universal decimal format (decimal separator is &#39;...