dolibarr  16.0.5
list.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2001-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2004-2016 Laurent Destailleur <eldy@users.sourceforge.net>
4  * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
5  * Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr>
6  * Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
7  * Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
8  * Copyright (C) 2016 Ferran Marcet <fmarcet@2byte.es>
9  * Copyright (C) 2018-2021 Frédéric France <frederic.france@netlogic.fr>
10  * Copyright (C) 2018-2022 Charlene Benke <charlene@patas-monkey.com>
11  * Copyright (C) 2019 Nicolas Zabouri <info@inovea-conseil.com>
12  * Copyright (C) 2021 Alexandre Spangaro <aspangaro@open-dsi.fr>
13  *
14  * This program is free software; you can redistribute it and/or modify
15  * it under the terms of the GNU General Public License as published by
16  * the Free Software Foundation; either version 3 of the License, or
17  * (at your option) any later version.
18  *
19  * This program is distributed in the hope that it will be useful,
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22  * GNU General Public License for more details.
23  *
24  * You should have received a copy of the GNU General Public License
25  * along with this program. If not, see <https://www.gnu.org/licenses/>.
26  */
27 
34 require '../../main.inc.php';
35 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
36 require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
37 require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php';
38 require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
39 require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
40 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
41 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formorder.class.php';
42 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
43 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
44 require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
45 require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
46 
47 $langs->loadLangs(array("orders", "sendings", 'deliveries', 'companies', 'compta', 'bills', 'projects', 'suppliers', 'products'));
48 
49 $action = GETPOST('action', 'aZ09');
50 $massaction = GETPOST('massaction', 'alpha');
51 $show_files = GETPOST('show_files', 'int');
52 $confirm = GETPOST('confirm', 'alpha');
53 $toselect = GETPOST('toselect', 'array');
54 $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'supplierorderlist';
55 
56 $search_date_order_startday = GETPOST('search_date_order_startday', 'int');
57 $search_date_order_startmonth = GETPOST('search_date_order_startmonth', 'int');
58 $search_date_order_startyear = GETPOST('search_date_order_startyear', 'int');
59 $search_date_order_endday = GETPOST('search_date_order_endday', 'int');
60 $search_date_order_endmonth = GETPOST('search_date_order_endmonth', 'int');
61 $search_date_order_endyear = GETPOST('search_date_order_endyear', 'int');
62 $search_date_order_start = dol_mktime(0, 0, 0, $search_date_order_startmonth, $search_date_order_startday, $search_date_order_startyear); // Use tzserver
63 $search_date_order_end = dol_mktime(23, 59, 59, $search_date_order_endmonth, $search_date_order_endday, $search_date_order_endyear);
64 $search_date_delivery_startday = GETPOST('search_date_delivery_startday', 'int');
65 $search_date_delivery_startmonth = GETPOST('search_date_delivery_startmonth', 'int');
66 $search_date_delivery_startyear = GETPOST('search_date_delivery_startyear', 'int');
67 $search_date_delivery_endday = GETPOST('search_date_delivery_endday', 'int');
68 $search_date_delivery_endmonth = GETPOST('search_date_delivery_endmonth', 'int');
69 $search_date_delivery_endyear = GETPOST('search_date_delivery_endyear', 'int');
70 $search_date_delivery_start = dol_mktime(0, 0, 0, $search_date_delivery_startmonth, $search_date_delivery_startday, $search_date_delivery_startyear); // Use tzserver
71 $search_date_delivery_end = dol_mktime(23, 59, 59, $search_date_delivery_endmonth, $search_date_delivery_endday, $search_date_delivery_endyear);
72 
73 $search_date_valid_startday = GETPOST('search_date_valid_startday', 'int');
74 $search_date_valid_startmonth = GETPOST('search_date_valid_startmonth', 'int');
75 $search_date_valid_startyear = GETPOST('search_date_valid_startyear', 'int');
76 $search_date_valid_endday = GETPOST('search_date_valid_endday', 'int');
77 $search_date_valid_endmonth = GETPOST('search_date_valid_endmonth', 'int');
78 $search_date_valid_endyear = GETPOST('search_date_valid_endyear', 'int');
79 $search_date_valid_start = dol_mktime(0, 0, 0, $search_date_valid_startmonth, $search_date_valid_startday, $search_date_valid_startyear); // Use tzserver
80 $search_date_valid_end = dol_mktime(23, 59, 59, $search_date_valid_endmonth, $search_date_valid_endday, $search_date_valid_endyear);
81 $search_date_approve_startday = GETPOST('search_date_approve_startday', 'int');
82 $search_date_approve_startmonth = GETPOST('search_date_approve_startmonth', 'int');
83 $search_date_approve_startyear = GETPOST('search_date_approve_startyear', 'int');
84 $search_date_approve_endday = GETPOST('search_date_approve_endday', 'int');
85 $search_date_approve_endmonth = GETPOST('search_date_approve_endmonth', 'int');
86 $search_date_approve_endyear = GETPOST('search_date_approve_endyear', 'int');
87 $search_date_approve_start = dol_mktime(0, 0, 0, $search_date_approve_startmonth, $search_date_approve_startday, $search_date_approve_startyear); // Use tzserver
88 $search_date_approve_end = dol_mktime(23, 59, 59, $search_date_approve_endmonth, $search_date_approve_endday, $search_date_approve_endyear);
89 
90 $sall = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml'));
91 
92 $search_product_category = GETPOST('search_product_category', 'int');
93 $search_ref = GETPOST('search_ref', 'alpha');
94 $search_refsupp = GETPOST('search_refsupp', 'alpha');
95 $search_company = GETPOST('search_company', 'alpha');
96 $search_town = GETPOST('search_town', 'alpha');
97 $search_zip = GETPOST('search_zip', 'alpha');
98 $search_state = GETPOST("search_state", 'alpha');
99 $search_country = GETPOST("search_country", 'int');
100 $search_type_thirdparty = GETPOST("search_type_thirdparty", 'int');
101 $search_user = GETPOST('search_user', 'int');
102 $search_request_author = GETPOST('search_request_author', 'alpha');
103 $search_ht = GETPOST('search_ht', 'alpha');
104 $search_ttc = GETPOST('search_ttc', 'alpha');
105 $optioncss = GETPOST('optioncss', 'alpha');
106 $socid = GETPOST('socid', 'int');
107 $search_sale = GETPOST('search_sale', 'int');
108 $search_total_ht = GETPOST('search_total_ht', 'alpha');
109 $search_total_tva = GETPOST('search_total_tva', 'alpha');
110 $search_total_ttc = GETPOST('search_total_ttc', 'alpha');
111 $search_multicurrency_code = GETPOST('search_multicurrency_code', 'alpha');
112 $search_multicurrency_tx = GETPOST('search_multicurrency_tx', 'alpha');
113 $search_multicurrency_montant_ht = GETPOST('search_multicurrency_montant_ht', 'alpha');
114 $search_multicurrency_montant_tva = GETPOST('search_multicurrency_montant_tva', 'alpha');
115 $search_multicurrency_montant_ttc = GETPOST('search_multicurrency_montant_ttc', 'alpha');
116 $optioncss = GETPOST('optioncss', 'alpha');
117 $search_billed = GETPOST('search_billed', 'int');
118 $search_project_ref = GETPOST('search_project_ref', 'alpha');
119 $search_btn = GETPOST('button_search', 'alpha');
120 $search_remove_btn = GETPOST('button_removefilter', 'alpha');
121 
122 if (is_array(GETPOST('search_status', 'none'))) { // 'none' because we want to know type before sanitizing
123  $search_status = join(',', GETPOST('search_status', 'array:intcomma'));
124 } else {
125  $search_status = (GETPOST('search_status', 'intcomma') != '' ? GETPOST('search_status', 'intcomma') : GETPOST('statut', 'intcomma'));
126 }
127 
128 // Security check
129 $orderid = GETPOST('orderid', 'int');
130 if ($user->socid) {
131  $socid = $user->socid;
132 }
133 $result = restrictedArea($user, 'fournisseur', $orderid, '', 'commande');
134 
135 $diroutputmassaction = $conf->fournisseur->commande->dir_output.'/temp/massgeneration/'.$user->id;
136 
137 $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
138 $sortfield = GETPOST('sortfield', 'aZ09comma');
139 $sortorder = GETPOST('sortorder', 'aZ09comma');
140 $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
141 if (empty($page) || $page == -1 || !empty($search_btn) || !empty($search_remove_btn) || (empty($toselect) && $massaction === '0')) {
142  $page = 0;
143 } // If $page is not defined, or '' or -1
144 $offset = $limit * $page;
145 $pageprev = $page - 1;
146 $pagenext = $page + 1;
147 if (!$sortfield) {
148  $sortfield = 'cf.ref';
149 }
150 if (!$sortorder) {
151  $sortorder = 'DESC';
152 }
153 
154 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
155 $object = new CommandeFournisseur($db);
156 $hookmanager->initHooks(array('supplierorderlist'));
157 $extrafields = new ExtraFields($db);
158 
159 // fetch optionals attributes and labels
160 $extrafields->fetch_name_optionals_label($object->table_element);
161 
162 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
163 
164 // List of fields to search into when doing a "search in all"
165 $fieldstosearchall = array();
166 foreach ($object->fields as $key => $val) {
167  if (!empty($val['searchall'])) {
168  $fieldstosearchall['cf.'.$key] = $val['label'];
169  }
170 }
171 $fieldstosearchall['pd.description'] = 'Description';
172 $fieldstosearchall['s.nom'] = "ThirdParty";
173 $fieldstosearchall['s.name_alias'] = "AliasNameShort";
174 $fieldstosearchall['s.zip'] = "Zip";
175 $fieldstosearchall['s.town'] = "Town";
176 if (empty($user->socid)) {
177  $fieldstosearchall["cf.note_private"] = "NotePrivate";
178 }
179 
180 $checkedtypetiers = 0;
181 
182 // Definition of array of fields for columns
183 $arrayfields = array(
184  's.town'=>array('label'=>"Town", 'enabled'=>1, 'position'=>47, 'checked'=>1),
185  's.zip'=>array('label'=>"Zip", 'enabled'=>1, 'position'=>47, 'checked'=>1),
186  'state.nom'=>array('label'=>"StateShort", 'enabled'=>1, 'position'=>48),
187  'country.code_iso'=>array('label'=>"Country", 'enabled'=>1, 'position'=>49),
188  'typent.code'=>array('label'=>"ThirdPartyType", 'enabled'=>$checkedtypetiers, 'position'=>50),
189  'u.login'=>array('label'=>"AuthorRequest", 'enabled'=>1, 'position'=>51)
190 );
191 foreach ($object->fields as $key => $val) {
192  // If $val['visible']==0, then we never show the field
193  if (!empty($val['visible'])) {
194  $visible = (int) dol_eval($val['visible'], 1);
195  $arrayfields['cf.'.$key] = array(
196  'label'=>$val['label'],
197  'checked'=>(($visible < 0) ? 0 : 1),
198  'enabled'=>(abs($visible) != 3 && dol_eval($val['enabled'], 1)),
199  'position'=>$val['position'],
200  'help'=> isset($val['help']) ? $val['help'] : ''
201  );
202  }
203 }
204 // Extra fields
205 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
206 
207 $object->fields = dol_sort_array($object->fields, 'position');
208 $arrayfields = dol_sort_array($arrayfields, 'position');
209 
210 $error = 0;
211 
212 $permissiontoread = ($user->rights->fournisseur->commande->lire || $user->rights->supplier_order->lire);
213 $permissiontoadd = ($user->rights->fournisseur->commande->creer || $user->rights->supplier_order->creer);
214 $permissiontodelete = ($user->rights->fournisseur->commande->supprimer || $user->rights->supplier_order->supprimer);
215 $permissiontovalidate = $permissiontoadd;
216 $permissiontoapprove = ($user->rights->fournisseur->commande->approuver || $user->rights->supplier_order->approuver);
217 
218 
219 /*
220  * Actions
221  */
222 
223 if (GETPOST('cancel', 'alpha')) {
224  $action = 'list'; $massaction = '';
225 }
226 if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createsupplierbills') {
227  $massaction = '';
228 }
229 
230 $parameters = array('socid'=>$socid);
231 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
232 if ($reshook < 0) {
233  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
234 }
235 
236 if (empty($reshook)) {
237  // Selection of new fields
238  include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
239 
240  // Purge search criteria
241  if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
242  $search_categ = '';
243  $search_user = '';
244  $search_sale = '';
245  $search_product_category = '';
246  $search_ref = '';
247  $search_refsupp = '';
248  $search_company = '';
249  $search_town = '';
250  $search_zip = "";
251  $search_state = "";
252  $search_type = '';
253  $search_country = '';
254  $search_type_thirdparty = '';
255  $search_request_author = '';
256  $search_total_ht = '';
257  $search_total_tva = '';
258  $search_total_ttc = '';
259  $search_multicurrency_code = '';
260  $search_multicurrency_tx = '';
261  $search_multicurrency_montant_ht = '';
262  $search_multicurrency_montant_tva = '';
263  $search_multicurrency_montant_ttc = '';
264  $search_project_ref = '';
265  $search_status = '';
266  $search_date_order_startday = '';
267  $search_date_order_startmonth = '';
268  $search_date_order_startyear = '';
269  $search_date_order_endday = '';
270  $search_date_order_endmonth = '';
271  $search_date_order_endyear = '';
272  $search_date_order_start = '';
273  $search_date_order_end = '';
274  $search_date_delivery_startday = '';
275  $search_date_delivery_startmonth = '';
276  $search_date_delivery_startyear = '';
277  $search_date_delivery_endday = '';
278  $search_date_delivery_endmonth = '';
279  $search_date_delivery_endyear = '';
280  $search_date_delivery_start = '';
281  $search_date_delivery_end = '';
282  $search_date_valid_startday = '';
283  $search_date_valid_startmonth = '';
284  $search_date_valid_startyear = '';
285  $search_date_valid_endday = '';
286  $search_date_valid_endmonth = '';
287  $search_date_valid_endyear = '';
288  $search_date_valid_start = '';
289  $search_date_valid_end = '';
290  $search_date_approve_startday = '';
291  $search_date_approve_startmonth = '';
292  $search_date_approve_startyear = '';
293  $search_date_approve_endday = '';
294  $search_date_approve_endmonth = '';
295  $search_date_approve_endyear = '';
296  $search_date_approve_start = '';
297  $search_date_approve_end = '';
298  $billed = '';
299  $search_billed = '';
300  $toselect = array();
301  $search_array_options = array();
302  }
303  if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')
304  || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) {
305  $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation
306  }
307 
308  // Mass actions
309  $objectclass = 'CommandeFournisseur';
310  $objectlabel = 'SupplierOrders';
311  $uploaddir = $conf->fournisseur->commande->dir_output;
312  include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
313 
314  if ($action == 'validate' && $permissiontovalidate) {
315  if (GETPOST('confirm') == 'yes') {
316  $objecttmp = new CommandeFournisseur($db);
317  $db->begin();
318  $error = 0;
319 
320  foreach ($toselect as $checked) {
321  if ($objecttmp->fetch($checked)) {
322  if ($objecttmp->statut == 0) {
323  $objecttmp->date_commande = dol_now();
324  $result = $objecttmp->valid($user);
325  if ($result >= 0) {
326  // If we have permission, and if we don't need to provide the idwarehouse, we go directly on approved step
327  if (empty($conf->global->SUPPLIER_ORDER_NO_DIRECT_APPROVE) && $permissiontoapprove && !(!empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER) && $objecttmp->hasProductsOrServices(1))) {
328  $result = $objecttmp->approve($user);
329  setEventMessages($langs->trans("SupplierOrderValidatedAndApproved"), array($objecttmp->ref));
330  } else {
331  setEventMessages($langs->trans("SupplierOrderValidated"), array($objecttmp->ref));
332  }
333  } else {
334  setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
335  $error++;
336  }
337  }
338  }
339  }
340 
341  if (!$error) $db->commit();
342  else $db->rollback();
343  }
344  }
345 
346  // Mass action to generate vendor bills
347  if ($massaction == 'confirm_createsupplierbills') {
348  $orders = GETPOST('toselect', 'array');
349  $createbills_onebythird = GETPOST('createbills_onebythird', 'int');
350  $validate_invoices = GETPOST('validate_invoices', 'int');
351 
352  $TFact = array();
353  $TFactThird = array();
354 
355  $nb_bills_created = 0;
356  $lastid = 0;
357  $lastref = '';
358 
359  $db->begin();
360 
361  $default_ref_supplier=dol_print_date(dol_now(), '%Y%m%d%H%M%S');
362 
363  foreach ($orders as $id_order) {
364  $cmd = new CommandeFournisseur($db);
365  if ($cmd->fetch($id_order) <= 0) {
366  continue;
367  }
368 
369  $objecttmp = new FactureFournisseur($db);
370  if (!empty($createbills_onebythird) && !empty($TFactThird[$cmd->socid])) {
371  $objecttmp = $TFactThird[$cmd->socid]; // If option "one bill per third" is set, we use already created order.
372  } else {
373  $objecttmp->socid = $cmd->socid;
374  $objecttmp->type = $objecttmp::TYPE_STANDARD;
375  $objecttmp->cond_reglement_id = $cmd->cond_reglement_id;
376  $objecttmp->mode_reglement_id = $cmd->mode_reglement_id;
377  $objecttmp->fk_project = $cmd->fk_project;
378  $objecttmp->multicurrency_code = $cmd->multicurrency_code;
379  $objecttmp->ref_supplier = !empty($cmd->ref_supplier) ? $cmd->ref_supplier : $default_ref_supplier;
380  $default_ref_supplier+=1;
381 
382  $datefacture = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int'));
383  if (empty($datefacture)) {
384  $datefacture = dol_now();
385  }
386 
387  $objecttmp->date = $datefacture;
388  $objecttmp->origin = 'order_supplier';
389  $objecttmp->origin_id = $id_order;
390 
391  $res = $objecttmp->create($user);
392 
393  if ($res > 0) {
394  $nb_bills_created++;
395  $lastref = $objecttmp->ref;
396  $lastid = $objecttmp->id;
397  }
398  }
399 
400  if ($objecttmp->id > 0) {
401  $sql = "INSERT INTO ".MAIN_DB_PREFIX."element_element (";
402  $sql .= "fk_source";
403  $sql .= ", sourcetype";
404  $sql .= ", fk_target";
405  $sql .= ", targettype";
406  $sql .= ") VALUES (";
407  $sql .= $id_order;
408  $sql .= ", '".$db->escape($objecttmp->origin)."'";
409  $sql .= ", ".((int) $objecttmp->id);
410  $sql .= ", '".$db->escape($objecttmp->element)."'";
411  $sql .= ")";
412 
413  if (!$db->query($sql)) {
414  $erorr++;
415  }
416 
417  if (!$error) {
418  $lines = $cmd->lines;
419  if (empty($lines) && method_exists($cmd, 'fetch_lines')) {
420  $cmd->fetch_lines();
421  $lines = $cmd->lines;
422  }
423 
424  $fk_parent_line = 0;
425  $num = count($lines);
426 
427  for ($i = 0; $i < $num; $i++) {
428  $desc = ($lines[$i]->desc ? $lines[$i]->desc : $lines[$i]->libelle);
429  if ($lines[$i]->subprice < 0) {
430  // Negative line, we create a discount line
431  $discount = new DiscountAbsolute($db);
432  $discount->fk_soc = $objecttmp->socid;
433  $discount->amount_ht = abs($lines[$i]->total_ht);
434  $discount->amount_tva = abs($lines[$i]->total_tva);
435  $discount->amount_ttc = abs($lines[$i]->total_ttc);
436  $discount->tva_tx = $lines[$i]->tva_tx;
437  $discount->fk_user = $user->id;
438  $discount->description = $desc;
439  $discountid = $discount->create($user);
440  if ($discountid > 0) {
441  $result = $objecttmp->insert_discount($discountid);
442  //$result=$discount->link_to_invoice($lineid,$id);
443  } else {
444  setEventMessages($discount->error, $discount->errors, 'errors');
445  $error++;
446  break;
447  }
448  } else {
449  // Positive line
450  $product_type = ($lines[$i]->product_type ? $lines[$i]->product_type : 0);
451  // Date start
452  $date_start = false;
453  if ($lines[$i]->date_debut_prevue) {
454  $date_start = $lines[$i]->date_debut_prevue;
455  }
456  if ($lines[$i]->date_debut_reel) {
457  $date_start = $lines[$i]->date_debut_reel;
458  }
459  if ($lines[$i]->date_start) {
460  $date_start = $lines[$i]->date_start;
461  }
462  //Date end
463  $date_end = false;
464  if ($lines[$i]->date_fin_prevue) {
465  $date_end = $lines[$i]->date_fin_prevue;
466  }
467  if ($lines[$i]->date_fin_reel) {
468  $date_end = $lines[$i]->date_fin_reel;
469  }
470  if ($lines[$i]->date_end) {
471  $date_end = $lines[$i]->date_end;
472  }
473  // Reset fk_parent_line for no child products and special product
474  if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9) {
475  $fk_parent_line = 0;
476  }
477  $result = $objecttmp->addline(
478  $desc,
479  $lines[$i]->subprice,
480  $lines[$i]->tva_tx,
481  $lines[$i]->localtax1_tx,
482  $lines[$i]->localtax2_tx,
483  $lines[$i]->qty,
484  $lines[$i]->fk_product,
485  $lines[$i]->remise_percent,
486  $date_start,
487  $date_end,
488  0,
489  $lines[$i]->info_bits,
490  'HT',
491  $product_type,
492  $lines[$i]->rang,
493  false,
494  $lines[$i]->array_options,
495  $lines[$i]->fk_unit,
496  $objecttmp->origin_id,
497  $lines[$i]->pa_ht,
498  $lines[$i]->ref_supplier,
499  $lines[$i]->special_code,
500  $fk_parent_line
501  );
502  if ($result > 0) {
503  $lineid = $result;
504  } else {
505  $lineid = 0;
506  $error++;
507  break;
508  }
509  // Defined the new fk_parent_line
510  if ($result > 0 && $lines[$i]->product_type == 9) {
511  $fk_parent_line = $result;
512  }
513  }
514  }
515  }
516  }
517 
518  $cmd->classifyBilled($user); // TODO Move this in workflow like done for customer orders
519 
520  if (!empty($createbills_onebythird) && empty($TFactThird[$cmd->socid])) {
521  $TFactThird[$cmd->socid] = $objecttmp;
522  } else {
523  $TFact[$objecttmp->id] = $objecttmp;
524  }
525  }
526 
527  // Build doc with all invoices
528  $TAllFact = empty($createbills_onebythird) ? $TFact : $TFactThird;
529  $toselect = array();
530 
531  if (!$error && $validate_invoices) {
532  $massaction = $action = 'builddoc';
533 
534  foreach ($TAllFact as &$objecttmp) {
535  $objecttmp->validate($user);
536  if ($result <= 0) {
537  $error++;
538  setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
539  break;
540  }
541 
542  $id = $objecttmp->id; // For builddoc action
543 
544  // Fac builddoc
545  $donotredirect = 1;
546  $upload_dir = $conf->fournisseur->facture->dir_output;
547  $permissiontoadd = ($user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer);
548  //include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
549  }
550 
551  $massaction = $action = 'confirm_createsupplierbills';
552  }
553 
554  if (!$error) {
555  $db->commit();
556 
557  if ($nb_bills_created == 1) {
558  $texttoshow = $langs->trans('BillXCreated', '{s1}');
559  $texttoshow = str_replace('{s1}', '<a href="'.DOL_URL_ROOT.'/fourn/facture/card.php?id='.urlencode($lastid).'">'.$lastref.'</a>', $texttoshow);
560  setEventMessages($texttoshow, null, 'mesgs');
561  } else {
562  setEventMessages($langs->trans('BillCreated', $nb_bills_created), null, 'mesgs');
563  }
564 
565  // Make a redirect to avoid to bill twice if we make a refresh or back
566  $param = '';
567  if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
568  $param .= '&contextpage='.urlencode($contextpage);
569  }
570  if ($limit > 0 && $limit != $conf->liste_limit) {
571  $param .= '&limit='.urlencode($limit);
572  }
573  if ($sall) {
574  $param .= '&sall='.urlencode($sall);
575  }
576  if ($socid > 0) {
577  $param .= '&socid='.urlencode($socid);
578  }
579  if ($search_status != '') {
580  $param .= '&search_status='.urlencode($search_status);
581  }
582  if ($search_date_order_startday) {
583  $param .= '&search_date_order_startday='.urlencode($search_date_order_startday);
584  }
585  if ($search_date_order_startmonth) {
586  $param .= '&search_date_order_startmonth='.urlencode($search_date_order_startmonth);
587  }
588  if ($search_date_order_startyear) {
589  $param .= '&search_date_order_startyear='.urlencode($search_date_order_startyear);
590  }
591  if ($search_date_order_endday) {
592  $param .= '&search_date_order_endday='.urlencode($search_date_order_endday);
593  }
594  if ($search_date_order_endmonth) {
595  $param .= '&search_date_order_endmonth='.urlencode($search_date_order_endmonth);
596  }
597  if ($search_date_order_endyear) {
598  $param .= '&search_date_order_endyear='.urlencode($search_date_order_endyear);
599  }
600  if ($search_date_delivery_startday) {
601  $param .= '&search_date_delivery_startday='.urlencode($search_date_delivery_startday);
602  }
603  if ($search_date_delivery_startmonth) {
604  $param .= '&search_date_delivery_startmonth='.urlencode($search_date_delivery_startmonth);
605  }
606  if ($search_date_delivery_startyear) {
607  $param .= '&search_date_delivery_startyear='.urlencode($search_date_delivery_startyear);
608  }
609  if ($search_date_delivery_endday) {
610  $param .= '&search_date_delivery_endday='.urlencode($search_date_delivery_endday);
611  }
612  if ($search_date_delivery_endmonth) {
613  $param .= '&search_date_delivery_endmonth='.urlencode($search_date_delivery_endmonth);
614  }
615  if ($search_date_delivery_endyear) {
616  $param .= '&search_date_delivery_endyear='.urlencode($search_date_delivery_endyear);
617  }
618  if ($search_date_valid_startday) {
619  $param .= '&search_date_valid_startday='.urlencode($search_date_valid_startday);
620  }
621  if ($search_date_valid_startmonth) {
622  $param .= '&search_date_valid_startmonth='.urlencode($search_date_valid_startmonth);
623  }
624  if ($search_date_valid_startyear) {
625  $param .= '&search_date_valid_startyear='.urlencode($search_date_valid_startyear);
626  }
627  if ($search_date_valid_endday) {
628  $param .= '&search_date_valid_endday='.urlencode($search_date_valid_endday);
629  }
630  if ($search_date_valid_endmonth) {
631  $param .= '&search_date_valid_endmonth='.urlencode($search_date_valid_endmonth);
632  }
633  if ($search_date_valid_endyear) {
634  $param .= '&search_date_valid_endyear='.urlencode($search_date_valid_endyear);
635  }
636  if ($search_date_approve_startday) {
637  $param .= '&search_date_approve_startday='.urlencode($search_date_approve_startday);
638  }
639  if ($search_date_approve_startmonth) {
640  $param .= '&search_date_approve_startmonth='.urlencode($search_date_approve_startmonth);
641  }
642  if ($search_date_approve_startyear) {
643  $param .= '&search_date_approve_startyear='.urlencode($search_date_approve_startyear);
644  }
645  if ($search_date_approve_endday) {
646  $param .= '&search_date_approve_endday='.urlencode($search_date_approve_endday);
647  }
648  if ($search_date_approve_endmonth) {
649  $param .= '&search_date_approve_endmonth='.urlencode($search_date_approve_endmonth);
650  }
651  if ($search_date_approve_endyear) {
652  $param .= '&search_date_approve_endyear='.urlencode($search_date_approve_endyear);
653  }
654  if ($search_ref) {
655  $param .= '&search_ref='.urlencode($search_ref);
656  }
657  if ($search_company) {
658  $param .= '&search_company='.urlencode($search_company);
659  }
660  //if ($search_ref_customer) $param .= '&search_ref_customer='.urlencode($search_ref_customer);
661  if ($search_user > 0) {
662  $param .= '&search_user='.urlencode($search_user);
663  }
664  if ($search_sale > 0) {
665  $param .= '&search_sale='.urlencode($search_sale);
666  }
667  if ($search_total_ht != '') {
668  $param .= '&search_total_ht='.urlencode($search_total_ht);
669  }
670  if ($search_total_tva != '') {
671  $param .= '&search_total_tva='.urlencode($search_total_tva);
672  }
673  if ($search_total_ttc != '') {
674  $param .= '&search_total_ttc='.urlencode($search_total_ttc);
675  }
676  if ($search_project_ref >= 0) {
677  $param .= "&search_project_ref=".urlencode($search_project_ref);
678  }
679  if ($show_files) {
680  $param .= '&show_files='.urlencode($show_files);
681  }
682  if ($optioncss != '') {
683  $param .= '&optioncss='.urlencode($optioncss);
684  }
685  if ($billed != '') {
686  $param .= '&billed='.urlencode($billed);
687  }
688 
689  header("Location: ".$_SERVER['PHP_SELF'].'?'.$param);
690  exit;
691  } else {
692  $db->rollback();
693  $action = 'create';
694  $_GET["origin"] = $_POST["origin"];
695  $_GET["originid"] = $_POST["originid"];
696  setEventMessages("Error", null, 'errors');
697  $error++;
698  }
699  }
700 }
701 
702 
703 /*
704  * View
705  */
706 
707 $now = dol_now();
708 
709 $form = new Form($db);
710 $thirdpartytmp = new Fournisseur($db);
711 $commandestatic = new CommandeFournisseur($db);
712 $formfile = new FormFile($db);
713 $formorder = new FormOrder($db);
714 $formother = new FormOther($db);
715 $formcompany = new FormCompany($db);
716 
717 $title = $langs->trans("SuppliersOrders");
718 if ($socid > 0) {
719  $fourn = new Fournisseur($db);
720  $fourn->fetch($socid);
721  $title .= ' - '.$fourn->name;
722 }
723 
724 /*if ($search_status)
725 {
726  if ($search_status == '1,2') $title .= ' - '.$langs->trans("SuppliersOrdersToProcess");
727  elseif ($search_status == '3,4') $title .= ' - '.$langs->trans("SuppliersOrdersAwaitingReception");
728  elseif ($search_status == '1,2,3') $title .= ' - '.$langs->trans("StatusOrderToProcessShort");
729  elseif ($search_status == '6,7') $title .= ' - '.$langs->trans("StatusOrderCanceled");
730  elseif (is_numeric($search_status) && $search_status >= 0) $title .= ' - '.$commandestatic->LibStatut($search_status);
731 }*/
732 if ($search_billed > 0) {
733  $title .= ' - '.$langs->trans("Billed");
734 }
735 
736 //$help_url="EN:Module_Customers_Orders|FR:Module_Commandes_Clients|ES:Módulo_Pedidos_de_clientes";
737 $help_url = '';
738 // llxHeader('',$title,$help_url);
739 
740 $sql = 'SELECT';
741 if ($sall || $search_product_category > 0) {
742  $sql = 'SELECT DISTINCT';
743 }
744 $sql .= ' s.rowid as socid, s.nom as name, s.town, s.zip, s.fk_pays, s.client, s.code_client, s.email,';
745 $sql .= " typent.code as typent_code,";
746 $sql .= " state.code_departement as state_code, state.nom as state_name,";
747 $sql .= " cf.rowid, cf.ref, cf.ref_supplier, cf.fk_statut, cf.billed, cf.total_ht, cf.total_tva, cf.total_ttc, cf.fk_user_author, cf.date_commande as date_commande, cf.date_livraison as date_livraison,cf.date_valid, cf.date_approve,";
748 $sql .= ' cf.fk_multicurrency, cf.multicurrency_code, cf.multicurrency_tx, cf.multicurrency_total_ht, cf.multicurrency_total_tva, cf.multicurrency_total_ttc,';
749 $sql .= ' cf.date_creation as date_creation, cf.tms as date_update,';
750 $sql .= ' cf.note_public, cf.note_private,';
751 $sql .= " p.rowid as project_id, p.ref as project_ref, p.title as project_title,";
752 $sql .= " u.firstname, u.lastname, u.photo, u.login, u.email as user_email, u.statut as user_status";
753 // Add fields from extrafields
754 if (!empty($extrafields->attributes[$object->table_element]['label'])) {
755  foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
756  $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : '');
757  }
758 }
759 // Add fields from hooks
760 $parameters = array();
761 $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook
762 $sql .= $hookmanager->resPrint;
763 $sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
764 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays)";
765 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typent)";
766 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)";
767 $sql .= ", ".MAIN_DB_PREFIX."commande_fournisseur as cf";
768 if (!empty($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
769  $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (cf.rowid = ef.fk_object)";
770 }
771 if ($sall || $search_product_category > 0) {
772  $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'commande_fournisseurdet as pd ON cf.rowid=pd.fk_commande';
773 }
774 if ($search_product_category > 0) {
775  $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product=pd.fk_product';
776 }
777 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON cf.fk_user_author = u.rowid";
778 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = cf.fk_projet";
779 // We'll need this table joined to the select in order to filter by sale
780 if ($search_sale > 0 || (empty($user->rights->societe->client->voir) && !$socid)) {
781  $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
782 }
783 $parameters = array();
784 $reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object); // Note that $action and $object may have been modified by hook
785 $sql .= $hookmanager->resPrint;
786 $sql .= ' WHERE cf.fk_soc = s.rowid';
787 $sql .= ' AND cf.entity IN ('.getEntity('supplier_order').')';
788 if ($socid > 0) {
789  $sql .= " AND s.rowid = ".((int) $socid);
790 }
791 if (empty($user->rights->societe->client->voir) && !$socid) {
792  $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
793 }
794 if ($search_ref) {
795  $sql .= natural_search('cf.ref', $search_ref);
796 }
797 if ($search_refsupp) {
798  $sql .= natural_search("cf.ref_supplier", $search_refsupp);
799 }
800 if ($sall) {
801  $sql .= natural_search(array_keys($fieldstosearchall), $sall);
802 }
803 if ($search_company) {
804  $sql .= natural_search('s.nom', $search_company);
805 }
806 if ($search_request_author) {
807  $sql .= natural_search(array('u.lastname', 'u.firstname', 'u.login'), $search_request_author);
808 }
809 if ($search_billed != '' && $search_billed >= 0) {
810  $sql .= " AND cf.billed = ".((int) $search_billed);
811 }
812 if ($search_product_category > 0) {
813  $sql .= " AND cp.fk_categorie = ".((int) $search_product_category);
814 }
815 //Required triple check because statut=0 means draft filter
816 if (GETPOST('statut', 'intcomma') !== '') {
817  $sql .= " AND cf.fk_statut IN (".$db->sanitize($db->escape($db->escape(GETPOST('statut', 'intcomma')))).")";
818 }
819 if ($search_status != '' && $search_status != '-1') {
820  $sql .= " AND cf.fk_statut IN (".$db->sanitize($db->escape($search_status)).")";
821 }
822 if ($search_date_order_start) {
823  $sql .= " AND cf.date_commande >= '".$db->idate($search_date_order_start)."'";
824 }
825 if ($search_date_order_end) {
826  $sql .= " AND cf.date_commande <= '".$db->idate($search_date_order_end)."'";
827 }
828 if ($search_date_delivery_start) {
829  $sql .= " AND cf.date_livraison >= '".$db->idate($search_date_delivery_start)."'";
830 }
831 if ($search_date_delivery_end) {
832  $sql .= " AND cf.date_livraison <= '".$db->idate($search_date_delivery_end)."'";
833 }
834 if ($search_date_valid_start) {
835  $sql .= " AND cf.date_commande >= '".$db->idate($search_date_valid_start)."'";
836 }
837 if ($search_date_valid_end) {
838  $sql .= " AND cf.date_commande <= '".$db->idate($search_date_valid_end)."'";
839 }
840 if ($search_date_approve_start) {
841  $sql .= " AND cf.date_livraison >= '".$db->idate($search_date_approve_start)."'";
842 }
843 if ($search_date_approve_end) {
844  $sql .= " AND cf.date_livraison <= '".$db->idate($search_date_approve_end)."'";
845 }
846 if ($search_town) {
847  $sql .= natural_search('s.town', $search_town);
848 }
849 if ($search_zip) {
850  $sql .= natural_search("s.zip", $search_zip);
851 }
852 if ($search_state) {
853  $sql .= natural_search("state.nom", $search_state);
854 }
855 if ($search_country) {
856  $sql .= " AND s.fk_pays IN (".$db->sanitize($db->escape($search_country)).')';
857 }
858 if ($search_type_thirdparty != '' && $search_type_thirdparty > 0) {
859  $sql .= " AND s.fk_typent IN (".$db->sanitize($db->escape($search_type_thirdparty)).')';
860 }
861 if ($search_company) {
862  $sql .= natural_search('s.nom', $search_company);
863 }
864 if ($search_sale > 0) {
865  $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $search_sale);
866 }
867 if ($search_user > 0) {
868  $sql .= " AND EXISTS (";
869  $sql .= " SELECT ec.rowid ";
870  $sql .= " FROM " . MAIN_DB_PREFIX . "element_contact as ec";
871  $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "c_type_contact as tc ON tc.rowid = ec.fk_c_type_contact";
872  $sql .= " WHERE ec.element_id = cf.rowid AND ec.fk_socpeople = " . ((int) $search_user);
873  $sql .= " AND tc.element = 'order_supplier' AND tc.source = 'internal'";
874  $sql .= ")";
875 }
876 if ($search_total_ht != '') {
877  $sql .= natural_search('cf.total_ht', $search_total_ht, 1);
878 }
879 if ($search_total_tva != '') {
880  $sql .= natural_search('cf.total_tva', $search_total_tva, 1);
881 }
882 if ($search_total_ttc != '') {
883  $sql .= natural_search('cf.total_ttc', $search_total_ttc, 1);
884 }
885 if ($search_multicurrency_code != '') {
886  $sql .= " AND cf.multicurrency_code = '".$db->escape($search_multicurrency_code)."'";
887 }
888 if ($search_multicurrency_tx != '') {
889  $sql .= natural_search('cf.multicurrency_tx', $search_multicurrency_tx, 1);
890 }
891 if ($search_multicurrency_montant_ht != '') {
892  $sql .= natural_search('cf.multicurrency_total_ht', $search_multicurrency_montant_ht, 1);
893 }
894 if ($search_multicurrency_montant_tva != '') {
895  $sql .= natural_search('cf.multicurrency_total_tva', $search_multicurrency_montant_tva, 1);
896 }
897 if ($search_multicurrency_montant_ttc != '') {
898  $sql .= natural_search('cf.multicurrency_total_ttc', $search_multicurrency_montant_ttc, 1);
899 }
900 if ($search_project_ref != '') {
901  $sql .= natural_search("p.ref", $search_project_ref);
902 }
903 // Add where from extra fields
904 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
905 // Add where from hooks
906 $parameters = array();
907 $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook
908 $sql .= $hookmanager->resPrint;
909 
910 $sql .= $db->order($sortfield, $sortorder);
911 
912 // Count total nb of records
913 $nbtotalofrecords = '';
914 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
915  $result = $db->query($sql);
916  $nbtotalofrecords = $db->num_rows($result);
917  if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
918  $page = 0;
919  $offset = 0;
920  }
921 }
922 
923 $sql .= $db->plimit($limit + 1, $offset);
924 //print $sql;
925 
926 $resql = $db->query($sql);
927 if ($resql) {
928  $num = $db->num_rows($resql);
929 
930  $arrayofselected = is_array($toselect) ? $toselect : array();
931 
932  if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $sall) {
933  $obj = $db->fetch_object($resql);
934  $id = $obj->rowid;
935  header("Location: ".DOL_URL_ROOT.'/fourn/commande/card.php?id='.$id);
936  exit;
937  }
938 
939  llxHeader('', $title, $help_url);
940 
941  $param = '';
942  if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
943  $param .= '&contextpage='.urlencode($contextpage);
944  }
945  if ($limit > 0 && $limit != $conf->liste_limit) {
946  $param .= '&limit='.urlencode($limit);
947  }
948  if ($sall) {
949  $param .= '&sall='.urlencode($sall);
950  }
951  if ($socid > 0) {
952  $param .= '&socid='.urlencode($socid);
953  }
954  if ($sall) {
955  $param .= "&search_all=".urlencode($sall);
956  }
957  if ($search_date_order_startday) {
958  $param .= '&search_date_order_startday='.urlencode($search_date_order_startday);
959  }
960  if ($search_date_order_startmonth) {
961  $param .= '&search_date_order_startmonth='.urlencode($search_date_order_startmonth);
962  }
963  if ($search_date_order_startyear) {
964  $param .= '&search_date_order_startyear='.urlencode($search_date_order_startyear);
965  }
966  if ($search_date_order_endday) {
967  $param .= '&search_date_order_endday='.urlencode($search_date_order_endday);
968  }
969  if ($search_date_order_endmonth) {
970  $param .= '&search_date_order_endmonth='.urlencode($search_date_order_endmonth);
971  }
972  if ($search_date_order_endyear) {
973  $param .= '&search_date_order_endyear='.urlencode($search_date_order_endyear);
974  }
975  if ($search_date_delivery_startday) {
976  $param .= '&search_date_delivery_startday='.urlencode($search_date_delivery_startday);
977  }
978  if ($search_date_delivery_startmonth) {
979  $param .= '&search_date_delivery_startmonth='.urlencode($search_date_delivery_startmonth);
980  }
981  if ($search_date_delivery_startyear) {
982  $param .= '&search_date_delivery_startyear='.urlencode($search_date_delivery_startyear);
983  }
984  if ($search_date_delivery_endday) {
985  $param .= '&search_date_delivery_endday='.urlencode($search_date_delivery_endday);
986  }
987  if ($search_date_delivery_endmonth) {
988  $param .= '&search_date_delivery_endmonth='.urlencode($search_date_delivery_endmonth);
989  }
990  if ($search_date_delivery_endyear) {
991  $param .= '&search_date_delivery_endyear='.urlencode($search_date_delivery_endyear);
992  }
993  if ($search_date_valid_startday) {
994  $param .= '&search_date_valid_startday='.urlencode($search_date_valid_startday);
995  }
996  if ($search_date_valid_startmonth) {
997  $param .= '&search_date_valid_startmonth='.urlencode($search_date_valid_startmonth);
998  }
999  if ($search_date_valid_startyear) {
1000  $param .= '&search_date_valid_startyear='.urlencode($search_date_valid_startyear);
1001  }
1002  if ($search_date_valid_endday) {
1003  $param .= '&search_date_valid_endday='.urlencode($search_date_valid_endday);
1004  }
1005  if ($search_date_valid_endmonth) {
1006  $param .= '&search_date_valid_endmonth='.urlencode($search_date_valid_endmonth);
1007  }
1008  if ($search_date_valid_endyear) {
1009  $param .= '&search_date_valid_endyear='.urlencode($search_date_valid_endyear);
1010  }
1011  if ($search_date_approve_startday) {
1012  $param .= '&search_date_approve_startday='.urlencode($search_date_approve_startday);
1013  }
1014  if ($search_date_approve_startmonth) {
1015  $param .= '&search_date_approve_startmonth='.urlencode($search_date_approve_startmonth);
1016  }
1017  if ($search_date_approve_startyear) {
1018  $param .= '&search_date_approve_startyear='.urlencode($search_date_approve_startyear);
1019  }
1020  if ($search_date_approve_endday) {
1021  $param .= '&search_date_approve_endday='.urlencode($search_date_approve_endday);
1022  }
1023  if ($search_date_approve_endmonth) {
1024  $param .= '&search_date_approve_endmonth='.urlencode($search_date_approve_endmonth);
1025  }
1026  if ($search_date_approve_endyear) {
1027  $param .= '&search_date_approve_endyear='.urlencode($search_date_approve_endyear);
1028  }
1029  if ($search_ref) {
1030  $param .= '&search_ref='.urlencode($search_ref);
1031  }
1032  if ($search_company) {
1033  $param .= '&search_company='.urlencode($search_company);
1034  }
1035  if ($search_user > 0) {
1036  $param .= '&search_user='.urlencode($search_user);
1037  }
1038  if ($search_request_author) {
1039  $param .= '&search_request_author='.urlencode($search_request_author);
1040  }
1041  if ($search_sale > 0) {
1042  $param .= '&search_sale='.urlencode($search_sale);
1043  }
1044  if ($search_total_ht != '') {
1045  $param .= '&search_total_ht='.urlencode($search_total_ht);
1046  }
1047  if ($search_total_ttc != '') {
1048  $param .= "&search_total_ttc=".urlencode($search_total_ttc);
1049  }
1050  if ($search_multicurrency_code != '') {
1051  $param .= '&search_multicurrency_code='.urlencode($search_multicurrency_code);
1052  }
1053  if ($search_multicurrency_tx != '') {
1054  $param .= '&search_multicurrency_tx='.urlencode($search_multicurrency_tx);
1055  }
1056  if ($search_multicurrency_montant_ht != '') {
1057  $param .= '&search_multicurrency_montant_ht='.urlencode($search_multicurrency_montant_ht);
1058  }
1059  if ($search_multicurrency_montant_tva != '') {
1060  $param .= '&search_multicurrency_montant_tva='.urlencode($search_multicurrency_montant_tva);
1061  }
1062  if ($search_multicurrency_montant_ttc != '') {
1063  $param .= '&search_multicurrency_montant_ttc='.urlencode($search_multicurrency_montant_ttc);
1064  }
1065  if ($search_refsupp) {
1066  $param .= "&search_refsupp=".urlencode($search_refsupp);
1067  }
1068  if ($search_status != '' && $search_status != '-1') {
1069  $param .= "&search_status=".urlencode($search_status);
1070  }
1071  if ($search_project_ref >= 0) {
1072  $param .= "&search_project_ref=".urlencode($search_project_ref);
1073  }
1074  if ($search_billed != '') {
1075  $param .= "&search_billed=".urlencode($search_billed);
1076  }
1077  if ($show_files) {
1078  $param .= '&show_files='.urlencode($show_files);
1079  }
1080  if ($optioncss != '') {
1081  $param .= '&optioncss='.urlencode($optioncss);
1082  }
1083  if ($search_type_thirdparty != '' && $search_type_thirdparty > 0) {
1084  $param .= '&search_type_thirdparty='.urlencode($search_type_thirdparty);
1085  }
1086 
1087  // Add $param from extra fields
1088  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
1089 
1090  $parameters = array();
1091  $reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object); // Note that $action and $object may have been modified by hook
1092  $param .= $hookmanager->resPrint;
1093 
1094  // List of mass actions available
1095  $arrayofmassactions = array(
1096  'generate_doc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("ReGeneratePDF"),
1097  'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
1098  'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
1099  );
1100 
1101  if ($permissiontovalidate) {
1102  if ($permissiontoapprove && empty($conf->global->SUPPLIER_ORDER_NO_DIRECT_APPROVE)) {
1103  $arrayofmassactions['prevalidate'] = img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("ValidateAndApprove");
1104  } else {
1105  $arrayofmassactions['prevalidate'] = img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("Validate");
1106  }
1107  }
1108 
1109  if ($user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer) {
1110  $arrayofmassactions['createbills'] = img_picto('', 'bill', 'class="pictofixedwidth"').$langs->trans("CreateInvoiceForThisSupplier");
1111  }
1112  if ($permissiontodelete) {
1113  $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
1114  }
1115  if (in_array($massaction, array('presend', 'predelete', 'createbills'))) {
1116  $arrayofmassactions = array();
1117  }
1118  $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
1119 
1120  $url = DOL_URL_ROOT.'/fourn/commande/card.php?action=create';
1121  if ($socid > 0) {
1122  $url .= '&socid='.((int) $socid);
1123  $url .= '&backtopage='.urlencode(DOL_URL_ROOT.'/fourn/commande/list.php?socid='.((int) $socid));
1124  }
1125  $newcardbutton = dolGetButtonTitle($langs->trans('NewSupplierOrderShort'), '', 'fa fa-plus-circle', $url, '', $permissiontoadd);
1126 
1127  // Lines of title fields
1128  print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
1129  if ($optioncss != '') {
1130  print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
1131  }
1132  print '<input type="hidden" name="token" value="'.newToken().'">';
1133  print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
1134  print '<input type="hidden" name="action" value="list">';
1135  print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
1136  print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
1137  print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
1138  print '<input type="hidden" name="socid" value="'.$socid.'">';
1139 
1140  print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'supplier_order', 0, $newcardbutton, '', $limit, 0, 0, 1);
1141 
1142  $topicmail = "SendOrderRef";
1143  $modelmail = "order_supplier_send";
1144  $objecttmp = new CommandeFournisseur($db);
1145  $trackid = 'sord'.$object->id;
1146  include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
1147 
1148  if ($massaction == 'prevalidate') {
1149  print $form->formconfirm($_SERVER["PHP_SELF"].$fieldstosearchall, $langs->trans("ConfirmMassValidation"), $langs->trans("ConfirmMassValidationQuestion"), "validate", null, '', 0, 200, 500, 1);
1150  }
1151 
1152  if ($massaction == 'createbills') {
1153  //var_dump($_REQUEST);
1154  print '<input type="hidden" name="massaction" value="confirm_createsupplierbills">';
1155 
1156  print '<table class="noborder" width="100%" >';
1157  print '<tr>';
1158  print '<td class="titlefield">';
1159  print $langs->trans('DateInvoice');
1160  print '</td>';
1161  print '<td>';
1162  print $form->selectDate('', '', '', '', '', '', 1, 1);
1163  print '</td>';
1164  print '</tr>';
1165  print '<tr>';
1166  print '<td>';
1167  print $langs->trans('CreateOneBillByThird');
1168  print '</td>';
1169  print '<td>';
1170  print $form->selectyesno('createbills_onebythird', '', 1);
1171  print '</td>';
1172  print '</tr>';
1173  print '<tr>';
1174  print '<td>';
1175  print $langs->trans('ValidateInvoices');
1176  print '</td>';
1177  print '<td>';
1178  print $form->selectyesno('validate_invoices', 1, 1);
1179  print '</td>';
1180  print '</tr>';
1181  print '</table>';
1182 
1183  print '<br>';
1184  print '<div class="center">';
1185  print '<input type="submit" class="button" id="createbills" name="createbills" value="'.$langs->trans('CreateInvoiceForThisCustomer').'"> ';
1186  print '<input type="submit" class="button button-cancel" id="cancel" name="cancel" value="'.$langs->trans("Cancel").'">';
1187  print '</div>';
1188  print '<br>';
1189  }
1190 
1191  if ($sall) {
1192  foreach ($fieldstosearchall as $key => $val) {
1193  $fieldstosearchall[$key] = $langs->trans($val);
1194  }
1195  print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'</div>';
1196  }
1197 
1198  $moreforfilter = '';
1199 
1200  // If the user can view prospects other than his'
1201  if ($user->rights->user->user->lire) {
1202  $langs->load("commercial");
1203  $moreforfilter .= '<div class="divsearchfield">';
1204  $tmptitle = $langs->trans('ThirdPartiesOfSaleRepresentative');
1205  $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, $tmptitle, 'maxwidth250 widthcentpercentminusx');
1206  $moreforfilter .= '</div>';
1207  }
1208  // If the user can view other users
1209  if ($user->rights->user->user->lire) {
1210  $moreforfilter .= '<div class="divsearchfield">';
1211  $tmptitle = $langs->trans('LinkedToSpecificUsers');
1212  $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$form->select_dolusers($search_user, 'search_user', $tmptitle, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth250 widthcentpercentminusx');
1213  $moreforfilter .= '</div>';
1214  }
1215  // If the user can view prospects other than his'
1216  if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire && ($user->rights->produit->lire || $user->rights->service->lire)) {
1217  include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
1218  $moreforfilter .= '<div class="divsearchfield">';
1219  $tmptitle = $langs->trans('IncludingProductWithTag');
1220  $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, null, 'parent', null, null, 1);
1221  $moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"').$form->selectarray('search_product_category', $cate_arbo, $search_product_category, $tmptitle, 0, 0, '', 0, 0, 0, 0, 'maxwidth300 widthcentpercentminusx', 1);
1222  $moreforfilter .= '</div>';
1223  }
1224  $parameters = array();
1225  $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook
1226  if (empty($reshook)) {
1227  $moreforfilter .= $hookmanager->resPrint;
1228  } else {
1229  $moreforfilter = $hookmanager->resPrint;
1230  }
1231 
1232  if (!empty($moreforfilter)) {
1233  print '<div class="liste_titre liste_titre_bydiv centpercent">';
1234  print $moreforfilter;
1235  print '</div>';
1236  }
1237 
1238  $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
1239  $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
1240  $selectedfields .= $form->showCheckAddButtons('checkforselect', 1);
1241 
1242  if (GETPOST('autoselectall', 'int')) {
1243  $selectedfields .= '<script>';
1244  $selectedfields .= ' $(document).ready(function() {';
1245  $selectedfields .= ' console.log("Autoclick on checkforselects");';
1246  $selectedfields .= ' $("#checkforselects").click();';
1247  $selectedfields .= ' $("#massaction").val("createbills").change();';
1248  $selectedfields .= ' });';
1249  $selectedfields .= '</script>';
1250  }
1251 
1252  print '<div class="div-table-responsive">';
1253  print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
1254 
1255  print '<tr class="liste_titre_filter">';
1256  // Ref
1257  if (!empty($arrayfields['cf.ref']['checked'])) {
1258  print '<td class="liste_titre"><input size="8" type="text" class="flat maxwidth75" name="search_ref" value="'.$search_ref.'"></td>';
1259  }
1260  // Ref customer
1261  if (!empty($arrayfields['cf.ref_supplier']['checked'])) {
1262  print '<td class="liste_titre"><input type="text" class="flat maxwidth75" name="search_refsupp" value="'.$search_refsupp.'"></td>';
1263  }
1264  // Project ref
1265  if (!empty($arrayfields['cf.fk_projet']['checked'])) {
1266  print '<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_project_ref" value="'.$search_project_ref.'"></td>';
1267  }
1268  // Request author
1269  if (!empty($arrayfields['u.login']['checked'])) {
1270  print '<td class="liste_titre">';
1271  print '<input type="text" class="flat" size="6" name="search_request_author" value="'.$search_request_author.'">';
1272  print '</td>';
1273  }
1274  // Thirpdarty
1275  if (!empty($arrayfields['cf.fk_soc']['checked'])) {
1276  print '<td class="liste_titre"><input type="text" size="6" class="flat" name="search_company" value="'.$search_company.'"></td>';
1277  }
1278  // Town
1279  if (!empty($arrayfields['s.town']['checked'])) {
1280  print '<td class="liste_titre"><input class="flat maxwidth50" type="text" name="search_town" value="'.$search_town.'"></td>';
1281  }
1282  // Zip
1283  if (!empty($arrayfields['s.zip']['checked'])) {
1284  print '<td class="liste_titre"><input class="flat maxwidth50" type="text" name="search_zip" value="'.$search_zip.'"></td>';
1285  }
1286  // State
1287  if (!empty($arrayfields['state.nom']['checked'])) {
1288  print '<td class="liste_titre">';
1289  print '<input class="flat maxwidth50" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).'">';
1290  print '</td>';
1291  }
1292  // Country
1293  if (!empty($arrayfields['country.code_iso']['checked'])) {
1294  print '<td class="liste_titre center">';
1295  print $form->select_country($search_country, 'search_country', '', 0, 'minwidth100imp maxwidth100');
1296  print '</td>';
1297  }
1298  // Company type
1299  if (!empty($arrayfields['typent.code']['checked'])) {
1300  print '<td class="liste_titre maxwidthonsmartphone center">';
1301  print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 1, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT), '', 1);
1302  print '</td>';
1303  }
1304  // Date order
1305  if (!empty($arrayfields['cf.date_commande']['checked'])) {
1306  print '<td class="liste_titre center">';
1307  print '<div class="nowrap">';
1308  print $form->selectDate($search_date_order_start ? $search_date_order_start : -1, 'search_date_order_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
1309  print '</div>';
1310  print '<div class="nowrap">';
1311  print $form->selectDate($search_date_order_end ? $search_date_order_end : -1, 'search_date_order_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
1312  print '</div>';
1313  print '</td>';
1314  }
1315  // Date delivery
1316  if (!empty($arrayfields['cf.date_livraison']['checked'])) {
1317  print '<td class="liste_titre center">';
1318  print '<div class="nowrap">';
1319  print $form->selectDate($search_date_delivery_start ? $search_date_delivery_start : -1, 'search_date_delivery_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
1320  print '</div>';
1321  print '<div class="nowrap">';
1322  print $form->selectDate($search_date_delivery_end ? $search_date_delivery_end : -1, 'search_date_delivery_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
1323  print '</div>';
1324  print '</td>';
1325  }
1326  if (!empty($arrayfields['cf.total_ht']['checked'])) {
1327  // Amount
1328  print '<td class="liste_titre right">';
1329  print '<input class="flat" type="text" size="5" name="search_total_ht" value="'.$search_total_ht.'">';
1330  print '</td>';
1331  }
1332  if (!empty($arrayfields['cf.total_tva']['checked'])) {
1333  // Amount
1334  print '<td class="liste_titre right">';
1335  print '<input class="flat" type="text" size="5" name="search_total_tva" value="'.$search_total_tva.'">';
1336  print '</td>';
1337  }
1338  if (!empty($arrayfields['cf.total_ttc']['checked'])) {
1339  // Amount
1340  print '<td class="liste_titre right">';
1341  print '<input class="flat" type="text" size="5" name="search_total_ttc" value="'.$search_total_ttc.'">';
1342  print '</td>';
1343  }
1344  if (!empty($arrayfields['cf.multicurrency_code']['checked'])) {
1345  // Currency
1346  print '<td class="liste_titre">';
1347  print $form->selectMultiCurrency($search_multicurrency_code, 'search_multicurrency_code', 1);
1348  print '</td>';
1349  }
1350  if (!empty($arrayfields['cf.multicurrency_tx']['checked'])) {
1351  // Currency rate
1352  print '<td class="liste_titre">';
1353  print '<input class="flat" type="text" size="4" name="search_multicurrency_tx" value="'.dol_escape_htmltag($search_multicurrency_tx).'">';
1354  print '</td>';
1355  }
1356  if (!empty($arrayfields['cf.multicurrency_total_ht']['checked'])) {
1357  // Amount
1358  print '<td class="liste_titre right">';
1359  print '<input class="flat" type="text" size="4" name="search_multicurrency_montant_ht" value="'.dol_escape_htmltag($search_multicurrency_montant_ht).'">';
1360  print '</td>';
1361  }
1362  if (!empty($arrayfields['cf.multicurrency_total_tva']['checked'])) {
1363  // Amount
1364  print '<td class="liste_titre right">';
1365  print '<input class="flat" type="text" size="4" name="search_multicurrency_montant_tva" value="'.dol_escape_htmltag($search_multicurrency_montant_tva).'">';
1366  print '</td>';
1367  }
1368  if (!empty($arrayfields['cf.multicurrency_total_ttc']['checked'])) {
1369  // Amount
1370  print '<td class="liste_titre right">';
1371  print '<input class="flat" type="text" size="4" name="search_multicurrency_montant_ttc" value="'.dol_escape_htmltag($search_multicurrency_montant_ttc).'">';
1372  print '</td>';
1373  }
1374  // Extra fields
1375  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
1376 
1377  // Fields from hook
1378  $parameters = array('arrayfields'=>$arrayfields);
1379  $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
1380  print $hookmanager->resPrint;
1381  // Date creation
1382  if (!empty($arrayfields['cf.date_creation']['checked'])) {
1383  print '<td class="liste_titre">';
1384  print '</td>';
1385  }
1386  // Date modification
1387  if (!empty($arrayfields['cf.tms']['checked'])) {
1388  print '<td class="liste_titre">';
1389  print '</td>';
1390  }
1391  // Status
1392  if (!empty($arrayfields['cf.fk_statut']['checked'])) {
1393  print '<td class="liste_titre right">';
1394  $formorder->selectSupplierOrderStatus($search_status, 1, 'search_status');
1395  print '</td>';
1396  }
1397  // Status billed
1398  if (!empty($arrayfields['cf.billed']['checked'])) {
1399  print '<td class="liste_titre center">';
1400  print $form->selectyesno('search_billed', $search_billed, 1, 0, 1, 1);
1401  print '</td>';
1402  }
1403  // Date valid
1404  if (!empty($arrayfields['cf.date_valid']['checked'])) {
1405  print '<td class="liste_titre center">';
1406  print '<div class="nowrap">';
1407  print $form->selectDate($search_date_valid_start ? $search_date_valid_start : -1, 'search_date_valid_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
1408  print '</div>';
1409  print '<div class="nowrap">';
1410  print $form->selectDate($search_date_valid_end ? $search_date_valid_end : -1, 'search_date_valid_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
1411  print '</div>';
1412  print '</td>';
1413  }
1414  // Date approve
1415  if (!empty($arrayfields['cf.date_approve']['checked'])) {
1416  print '<td class="liste_titre center">';
1417  print '<div class="nowrap">';
1418  print $form->selectDate($search_date_approve_start ? $search_date_approve_start : -1, 'search_date_approve_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
1419  print '</div>';
1420  print '<div class="nowrap">';
1421  print $form->selectDate($search_date_approve_end ? $search_date_approve_end : -1, 'search_date_approve_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
1422  print '</div>';
1423  print '</td>';
1424  }
1425  // Action column
1426  print '<td class="liste_titre middle">';
1427  $searchpicto = $form->showFilterButtons();
1428  print $searchpicto;
1429  print '</td>';
1430 
1431  print "</tr>\n";
1432 
1433  // Fields title
1434  print '<tr class="liste_titre">';
1435  if (!empty($arrayfields['cf.ref']['checked'])) {
1436  print_liste_field_titre($arrayfields['cf.ref']['label'], $_SERVER["PHP_SELF"], "cf.ref", "", $param, '', $sortfield, $sortorder);
1437  }
1438  if (!empty($arrayfields['cf.ref_supplier']['checked'])) {
1439  print_liste_field_titre($arrayfields['cf.ref_supplier']['label'], $_SERVER["PHP_SELF"], "cf.ref_supplier", "", $param, '', $sortfield, $sortorder, 'tdoverflowmax100imp ');
1440  }
1441  if (!empty($arrayfields['cf.fk_projet']['checked'])) {
1442  print_liste_field_titre($arrayfields['cf.fk_projet']['label'], $_SERVER["PHP_SELF"], "p.ref", "", $param, '', $sortfield, $sortorder);
1443  }
1444  if (!empty($arrayfields['u.login']['checked'])) {
1445  print_liste_field_titre($arrayfields['u.login']['label'], $_SERVER["PHP_SELF"], "u.login", "", $param, '', $sortfield, $sortorder);
1446  }
1447  if (!empty($arrayfields['cf.fk_soc']['checked'])) {
1448  print_liste_field_titre($arrayfields['cf.fk_soc']['label'], $_SERVER["PHP_SELF"], "s.nom", "", $param, '', $sortfield, $sortorder);
1449  }
1450  if (!empty($arrayfields['s.town']['checked'])) {
1451  print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], 's.town', '', $param, '', $sortfield, $sortorder);
1452  }
1453  if (!empty($arrayfields['s.zip']['checked'])) {
1454  print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], 's.zip', '', $param, '', $sortfield, $sortorder);
1455  }
1456  if (!empty($arrayfields['state.nom']['checked'])) {
1457  print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder);
1458  }
1459  if (!empty($arrayfields['country.code_iso']['checked'])) {
1460  print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, '', $sortfield, $sortorder, 'center ');
1461  }
1462  if (!empty($arrayfields['typent.code']['checked'])) {
1463  print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, '', $sortfield, $sortorder, 'center ');
1464  }
1465  if (!empty($arrayfields['cf.fk_author']['checked'])) {
1466  print_liste_field_titre($arrayfields['cf.fk_author']['label'], $_SERVER["PHP_SELF"], "cf.fk_author", "", $param, '', $sortfield, $sortorder);
1467  }
1468  if (!empty($arrayfields['cf.date_commande']['checked'])) {
1469  print_liste_field_titre($arrayfields['cf.date_commande']['label'], $_SERVER["PHP_SELF"], "cf.date_commande", "", $param, '', $sortfield, $sortorder, 'center ');
1470  }
1471  if (!empty($arrayfields['cf.date_livraison']['checked'])) {
1472  print_liste_field_titre($arrayfields['cf.date_livraison']['label'], $_SERVER["PHP_SELF"], 'cf.date_livraison', '', $param, '', $sortfield, $sortorder, 'center ');
1473  }
1474  if (!empty($arrayfields['cf.total_ht']['checked'])) {
1475  print_liste_field_titre($arrayfields['cf.total_ht']['label'], $_SERVER["PHP_SELF"], "cf.total_ht", "", $param, '', $sortfield, $sortorder, 'right ');
1476  }
1477  if (!empty($arrayfields['cf.total_tva']['checked'])) {
1478  print_liste_field_titre($arrayfields['cf.total_tva']['label'], $_SERVER["PHP_SELF"], "cf.total_tva", "", $param, '', $sortfield, $sortorder, 'right ');
1479  }
1480  if (!empty($arrayfields['cf.total_ttc']['checked'])) {
1481  print_liste_field_titre($arrayfields['cf.total_ttc']['label'], $_SERVER["PHP_SELF"], "cf.total_ttc", "", $param, '', $sortfield, $sortorder, 'right ');
1482  }
1483  if (!empty($arrayfields['cf.multicurrency_code']['checked'])) {
1484  print_liste_field_titre($arrayfields['cf.multicurrency_code']['label'], $_SERVER['PHP_SELF'], 'cf.multicurrency_code', '', $param, '', $sortfield, $sortorder);
1485  }
1486  if (!empty($arrayfields['cf.multicurrency_tx']['checked'])) {
1487  print_liste_field_titre($arrayfields['cf.multicurrency_tx']['label'], $_SERVER['PHP_SELF'], 'cf.multicurrency_tx', '', $param, '', $sortfield, $sortorder);
1488  }
1489  if (!empty($arrayfields['cf.multicurrency_total_ht']['checked'])) {
1490  print_liste_field_titre($arrayfields['cf.multicurrency_total_ht']['label'], $_SERVER['PHP_SELF'], 'cf.multicurrency_total_ht', '', $param, 'class="right"', $sortfield, $sortorder);
1491  }
1492  if (!empty($arrayfields['cf.multicurrency_total_tva']['checked'])) {
1493  print_liste_field_titre($arrayfields['cf.multicurrency_total_tva']['label'], $_SERVER['PHP_SELF'], 'cf.multicurrency_total_tva', '', $param, 'class="right"', $sortfield, $sortorder);
1494  }
1495  if (!empty($arrayfields['cf.multicurrency_total_ttc']['checked'])) {
1496  print_liste_field_titre($arrayfields['cf.multicurrency_total_ttc']['label'], $_SERVER['PHP_SELF'], 'cf.multicurrency_total_ttc', '', $param, 'class="right"', $sortfield, $sortorder);
1497  }
1498  // Extra fields
1499  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
1500  // Hook fields
1501  $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
1502  $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
1503  print $hookmanager->resPrint;
1504  if (!empty($arrayfields['cf.date_creation']['checked'])) {
1505  print_liste_field_titre($arrayfields['cf.date_creation']['label'], $_SERVER["PHP_SELF"], "cf.date_creation", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
1506  }
1507  if (!empty($arrayfields['cf.tms']['checked'])) {
1508  print_liste_field_titre($arrayfields['cf.tms']['label'], $_SERVER["PHP_SELF"], "cf.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
1509  }
1510  if (!empty($arrayfields['cf.fk_statut']['checked'])) {
1511  print_liste_field_titre($arrayfields['cf.fk_statut']['label'], $_SERVER["PHP_SELF"], "cf.fk_statut", "", $param, '', $sortfield, $sortorder, 'right ');
1512  }
1513  if (!empty($arrayfields['cf.billed']['checked'])) {
1514  print_liste_field_titre($arrayfields['cf.billed']['label'], $_SERVER["PHP_SELF"], 'cf.billed', '', $param, '', $sortfield, $sortorder, 'center ');
1515  }
1516  if (!empty($arrayfields['cf.date_valid']['checked'])) {
1517  print_liste_field_titre($arrayfields['cf.date_valid']['label'], $_SERVER["PHP_SELF"], "cf.date_valid", "", $param, '', $sortfield, $sortorder, 'center ');
1518  }
1519  if (!empty($arrayfields['cf.date_approve']['checked'])) {
1520  print_liste_field_titre($arrayfields['cf.date_approve']['label'], $_SERVER["PHP_SELF"], 'cf.date_approve', '', $param, '', $sortfield, $sortorder, 'center ');
1521  }
1522  print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
1523  print "</tr>\n";
1524 
1525 
1526  $total = 0;
1527  $subtotal = 0;
1528  $productstat_cache = array();
1529 
1530  $userstatic = new User($db);
1531  $objectstatic = new CommandeFournisseur($db);
1532  $projectstatic = new Project($db);
1533 
1534  $i = 0;
1535  $totalarray = array('nbfield' => 0, 'val' => array(), 'pos' => array());
1536  $totalarray['val']['cf.total_ht'] = 0;
1537  $totalarray['val']['cf.total_ttc'] = 0;
1538  $totalarray['val']['cf.total_tva'] = 0;
1539 
1540  $imaxinloop = ($limit ? min($num, $limit) : $num);
1541  while ($i < $imaxinloop) {
1542  $obj = $db->fetch_object($resql);
1543 
1544  $notshippable = 0;
1545  $warning = 0;
1546  $text_info = '';
1547  $text_warning = '';
1548  $nbprod = 0;
1549 
1550  $objectstatic->id = $obj->rowid;
1551  $objectstatic->ref = $obj->ref;
1552  $objectstatic->socid = $obj->socid;
1553  $objectstatic->ref_supplier = $obj->ref_supplier;
1554  $objectstatic->socid = $obj->socid;
1555  $objectstatic->total_ht = $obj->total_ht;
1556  $objectstatic->total_tva = $obj->total_tva;
1557  $objectstatic->total_ttc = $obj->total_ttc;
1558  $objectstatic->date_commande = $db->jdate($obj->date_commande);
1559  $objectstatic->delivery_date = $db->jdate($obj->date_livraison);
1560  $objectstatic->note_public = $obj->note_public;
1561  $objectstatic->note_private = $obj->note_private;
1562  $objectstatic->statut = $obj->fk_statut;
1563 
1564  print '<tr class="oddeven">';
1565 
1566  // Ref
1567  if (!empty($arrayfields['cf.ref']['checked'])) {
1568  print '<td class="nowrap">';
1569 
1570  // Picto + Ref
1571  print $objectstatic->getNomUrl(1, '', 0, -1, 1);
1572  // Other picto tool
1573  $filename = dol_sanitizeFileName($obj->ref);
1574  $filedir = $conf->fournisseur->commande->dir_output.'/'.dol_sanitizeFileName($obj->ref);
1575  print $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir);
1576 
1577  print '</td>'."\n";
1578  if (!$i) {
1579  $totalarray['nbfield']++;
1580  }
1581  }
1582  // Ref Supplier
1583  if (!empty($arrayfields['cf.ref_supplier']['checked'])) {
1584  print '<td>'.$obj->ref_supplier.'</td>'."\n";
1585  if (!$i) {
1586  $totalarray['nbfield']++;
1587  }
1588  }
1589  // Project
1590  if (!empty($arrayfields['cf.fk_projet']['checked'])) {
1591  $projectstatic->id = $obj->project_id;
1592  $projectstatic->ref = $obj->project_ref;
1593  $projectstatic->title = $obj->project_title;
1594  print '<td>';
1595  if ($obj->project_id > 0) {
1596  print $projectstatic->getNomUrl(1);
1597  }
1598  print '</td>';
1599  if (!$i) {
1600  $totalarray['nbfield']++;
1601  }
1602  }
1603  // Author
1604  $userstatic->id = $obj->fk_user_author;
1605  $userstatic->lastname = $obj->lastname;
1606  $userstatic->firstname = $obj->firstname;
1607  $userstatic->login = $obj->login;
1608  $userstatic->photo = $obj->photo;
1609  $userstatic->email = $obj->user_email;
1610  $userstatic->statut = $obj->user_status;
1611  if (!empty($arrayfields['u.login']['checked'])) {
1612  print '<td class="tdoverflowmax150">';
1613  if ($userstatic->id) {
1614  print $userstatic->getNomUrl(1);
1615  }
1616  print "</td>";
1617  if (!$i) {
1618  $totalarray['nbfield']++;
1619  }
1620  }
1621  // Thirdparty
1622  if (!empty($arrayfields['cf.fk_soc']['checked'])) {
1623  print '<td class="tdoverflowmax150">';
1624  $thirdpartytmp->id = $obj->socid;
1625  $thirdpartytmp->name = $obj->name;
1626  $thirdpartytmp->email = $obj->email;
1627  print $thirdpartytmp->getNomUrl(1, 'supplier');
1628  print '</td>'."\n";
1629  if (!$i) {
1630  $totalarray['nbfield']++;
1631  }
1632  }
1633  // Town
1634  if (!empty($arrayfields['s.town']['checked'])) {
1635  print '<td>';
1636  print $obj->town;
1637  print '</td>';
1638  if (!$i) {
1639  $totalarray['nbfield']++;
1640  }
1641  }
1642  // Zip
1643  if (!empty($arrayfields['s.zip']['checked'])) {
1644  print '<td>';
1645  print $obj->zip;
1646  print '</td>';
1647  if (!$i) {
1648  $totalarray['nbfield']++;
1649  }
1650  }
1651  // State
1652  if (!empty($arrayfields['state.nom']['checked'])) {
1653  print "<td>".$obj->state_name."</td>\n";
1654  if (!$i) {
1655  $totalarray['nbfield']++;
1656  }
1657  }
1658  // Country
1659  if (!empty($arrayfields['country.code_iso']['checked'])) {
1660  print '<td class="center">';
1661  $tmparray = getCountry($obj->fk_pays, 'all');
1662  print $tmparray['label'];
1663  print '</td>';
1664  if (!$i) {
1665  $totalarray['nbfield']++;
1666  }
1667  }
1668  // Type ent
1669  if (!empty($arrayfields['typent.code']['checked'])) {
1670  print '<td class="center">';
1671  if (empty($typenArray)) {
1672  $typenArray = $formcompany->typent_array(1);
1673  }
1674  print $typenArray[$obj->typent_code];
1675  print '</td>';
1676  if (!$i) {
1677  $totalarray['nbfield']++;
1678  }
1679  }
1680 
1681  // Order date
1682  if (!empty($arrayfields['cf.date_commande']['checked'])) {
1683  print '<td class="center">';
1684  print dol_print_date($db->jdate($obj->date_commande), 'day');
1685  if ($objectstatic->statut != $objectstatic::STATUS_ORDERSENT && $objectstatic->statut != $objectstatic::STATUS_RECEIVED_PARTIALLY) {
1686  if ($objectstatic->hasDelay()) {
1687  print ' '.img_picto($langs->trans("Late").' : '.$objectstatic->showDelay(), "warning");
1688  }
1689  }
1690  print '</td>';
1691  if (!$i) {
1692  $totalarray['nbfield']++;
1693  }
1694  }
1695  // Plannned date of delivery
1696  if (!empty($arrayfields['cf.date_livraison']['checked'])) {
1697  print '<td class="center">';
1698  print dol_print_date($db->jdate($obj->date_livraison), 'day');
1699  if ($objectstatic->statut == $objectstatic::STATUS_ORDERSENT || $objectstatic->statut == $objectstatic::STATUS_RECEIVED_PARTIALLY) {
1700  if ($objectstatic->hasDelay()) {
1701  print ' '.img_picto($langs->trans("Late").' : '.$objectstatic->showDelay(), "warning");
1702  }
1703  }
1704  print '</td>';
1705  if (!$i) {
1706  $totalarray['nbfield']++;
1707  }
1708  }
1709  // Amount HT
1710  if (!empty($arrayfields['cf.total_ht']['checked'])) {
1711  print '<td class="right"><span class="amount">'.price($obj->total_ht)."</span></td>\n";
1712  if (!$i) {
1713  $totalarray['nbfield']++;
1714  }
1715  if (!$i) {
1716  $totalarray['pos'][$totalarray['nbfield']] = 'cf.total_ht';
1717  }
1718  $totalarray['val']['cf.total_ht'] += $obj->total_ht;
1719  }
1720  // Amount VAT
1721  if (!empty($arrayfields['cf.total_tva']['checked'])) {
1722  print '<td class="right"><span class="amount">'.price($obj->total_tva)."</span></td>\n";
1723  if (!$i) {
1724  $totalarray['nbfield']++;
1725  }
1726  if (!$i) {
1727  $totalarray['pos'][$totalarray['nbfield']] = 'cf.total_tva';
1728  }
1729  $totalarray['val']['cf.total_tva'] += $obj->total_tva;
1730  }
1731  // Amount TTC
1732  if (!empty($arrayfields['cf.total_ttc']['checked'])) {
1733  print '<td class="right"><span class="amount">'.price($obj->total_ttc)."</span></td>\n";
1734  if (!$i) {
1735  $totalarray['nbfield']++;
1736  }
1737  if (!$i) {
1738  $totalarray['pos'][$totalarray['nbfield']] = 'cf.total_ttc';
1739  }
1740  $totalarray['val']['cf.total_ttc'] += $obj->total_ttc;
1741  }
1742 
1743  // Currency
1744  if (!empty($arrayfields['cf.multicurrency_code']['checked'])) {
1745  print '<td class="nowrap">'.$obj->multicurrency_code.' - '.$langs->trans('Currency'.$obj->multicurrency_code)."</td>\n";
1746  if (!$i) {
1747  $totalarray['nbfield']++;
1748  }
1749  }
1750 
1751  // Currency rate
1752  if (!empty($arrayfields['cf.multicurrency_tx']['checked'])) {
1753  print '<td class="nowrap">';
1754  $form->form_multicurrency_rate($_SERVER['PHP_SELF'].'?id='.$obj->rowid, $obj->multicurrency_tx, 'none', $obj->multicurrency_code);
1755  print "</td>\n";
1756  if (!$i) {
1757  $totalarray['nbfield']++;
1758  }
1759  }
1760  // Amount HT
1761  if (!empty($arrayfields['cf.multicurrency_total_ht']['checked'])) {
1762  print '<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_ht)."</span></td>\n";
1763  if (!$i) {
1764  $totalarray['nbfield']++;
1765  }
1766  }
1767  // Amount VAT
1768  if (!empty($arrayfields['cf.multicurrency_total_tva']['checked'])) {
1769  print '<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_tva)."</span></td>\n";
1770  if (!$i) {
1771  $totalarray['nbfield']++;
1772  }
1773  }
1774  // Amount TTC
1775  if (!empty($arrayfields['cf.multicurrency_total_ttc']['checked'])) {
1776  print '<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_ttc)."</span></td>\n";
1777  if (!$i) {
1778  $totalarray['nbfield']++;
1779  }
1780  }
1781 
1782  // Extra fields
1783  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
1784  // Fields from hook
1785  $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
1786  $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook
1787  print $hookmanager->resPrint;
1788  // Date creation
1789  if (!empty($arrayfields['cf.date_creation']['checked'])) {
1790  print '<td class="center nowrap">';
1791  print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser');
1792  print '</td>';
1793  if (!$i) {
1794  $totalarray['nbfield']++;
1795  }
1796  }
1797  // Date modification
1798  if (!empty($arrayfields['cf.tms']['checked'])) {
1799  print '<td class="center nowrap">';
1800  print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser');
1801  print '</td>';
1802  if (!$i) {
1803  $totalarray['nbfield']++;
1804  }
1805  }
1806  // Status
1807  if (!empty($arrayfields['cf.fk_statut']['checked'])) {
1808  print '<td class="right nowrap">'.$objectstatic->LibStatut($obj->fk_statut, 5, $obj->billed).'</td>';
1809  if (!$i) {
1810  $totalarray['nbfield']++;
1811  }
1812  }
1813  // Billed
1814  if (!empty($arrayfields['cf.billed']['checked'])) {
1815  print '<td class="center">'.yn($obj->billed).'</td>';
1816  if (!$i) {
1817  $totalarray['nbfield']++;
1818  }
1819  }
1820 
1821  // valid date
1822  if (!empty($arrayfields['cf.date_valid']['checked'])) {
1823  print '<td class="center">';
1824  print dol_print_date($db->jdate($obj->date_valid), 'day');
1825  print '</td>';
1826  if (!$i) {
1827  $totalarray['nbfield']++;
1828  }
1829  }
1830  // approve date
1831  if (!empty($arrayfields['cf.date_approve']['checked'])) {
1832  print '<td class="center">';
1833  print dol_print_date($db->jdate($obj->date_approve), 'day');
1834  print '</td>';
1835  if (!$i) {
1836  $totalarray['nbfield']++;
1837  }
1838  }
1839 
1840  // Action column
1841  print '<td class="nowrap center">';
1842  if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
1843  $selected = 0;
1844  if (in_array($obj->rowid, $arrayofselected)) {
1845  $selected = 1;
1846  }
1847  print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
1848  }
1849  print '</td>';
1850  if (!$i) {
1851  $totalarray['nbfield']++;
1852  }
1853 
1854  print "</tr>\n";
1855 
1856  $total += $obj->total_ht;
1857  $subtotal += $obj->total_ht;
1858  $i++;
1859  }
1860 
1861  // Show total line
1862  include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
1863 
1864  // If no record found
1865  if ($num == 0) {
1866  $colspan = 1;
1867  foreach ($arrayfields as $key => $val) {
1868  if (!empty($val['checked'])) {
1869  $colspan++;
1870  }
1871  }
1872  print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
1873  }
1874 
1875  $db->free($resql);
1876 
1877  $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql);
1878  $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook
1879  print $hookmanager->resPrint;
1880 
1881  print '</table>'."\n";
1882  print '</div>';
1883 
1884  print '</form>'."\n";
1885 
1886  $hidegeneratedfilelistifempty = 1;
1887  if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) {
1888  $hidegeneratedfilelistifempty = 0;
1889  }
1890 
1891  // Show list of available documents
1892  $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
1893  $urlsource .= str_replace('&amp;', '&', $param);
1894 
1895  $filedir = $diroutputmassaction;
1896  $genallowed = $permissiontoread;
1897  $delallowed = $permissiontoadd;
1898 
1899  print $formfile->showdocuments('massfilesarea_supplier_order', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
1900 } else {
1901  dol_print_error($db);
1902 }
1903 
1904 // End of page
1905 llxFooter();
1906 $db->close();
dol_sanitizeFileName
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
Definition: functions.lib.php:1226
restrictedArea
restrictedArea($user, $features, $objectid=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.
Definition: security.lib.php:234
llxFooter
llxFooter()
Empty footer.
Definition: wrapper.php:73
Project
Class to manage projects.
Definition: project.class.php:35
GETPOST
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Definition: functions.lib.php:484
FactureFournisseur
Class to manage suppliers invoices.
Definition: fournisseur.facture.class.php:53
dol_print_error
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
Definition: functions.lib.php:4844
dol_sort_array
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by second index function, which produces ascending (default) or descending output...
Definition: functions.lib.php:8385
FormOrder
Class to manage HTML output components for orders Before adding component here, check they are not in...
Definition: html.formorder.class.php:31
$form
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:142
FormOther
Classe permettant la generation de composants html autre Only common components are here.
Definition: html.formother.class.php:39
$help_url
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save" &&empty($cancel)) $help_url
View.
Definition: agenda.php:116
dol_print_date
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
Definition: functions.lib.php:2514
FormCompany
Class to build HTML component for third parties management Only common components are here.
Definition: html.formcompany.class.php:40
img_picto
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
Definition: functions.lib.php:3880
FormFile
Class to offer components to list and upload files.
Definition: html.formfile.class.php:36
Fournisseur
Class to manage suppliers.
Definition: fournisseur.class.php:34
dolGetButtonTitle
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
Definition: functions.lib.php:10605
DiscountAbsolute
Class to manage absolute discounts.
Definition: discount.class.php:29
print_barre_liste
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.
Definition: functions.lib.php:5257
CommandeFournisseur
Class to manage predefined suppliers products.
Definition: fournisseur.commande.class.php:47
User
Class to manage Dolibarr users.
Definition: user.class.php:44
GETPOSTISSET
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
Definition: functions.lib.php:386
print_liste_field_titre
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
Definition: functions.lib.php:5026
natural_search
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...
Definition: functions.lib.php:9420
dol_eval
dol_eval($s, $returnvalue=0, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
Definition: functions.lib.php:8611
ExtraFields
Class to manage standard extra fields.
Definition: extrafields.class.php:39
Form
Class to manage generation of HTML components Only common components must be here.
Definition: html.form.class.php:52
dol_now
dol_now($mode='auto')
Return date for now.
Definition: functions.lib.php:2845
$resql
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->facture->lire)||(isModEnabled('supplier_invoice') && $user->rights->supplier_invoice->lire)) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
Definition: index.php:742
getCountry
getCountry($searchkey, $withcode='', $dbtouse=0, $outputlangs='', $entconv=1, $searchlabel='')
Return country label, code or id from an id, code or label.
Definition: company.lib.php:489
setEventMessages
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
Definition: functions.lib.php:8137
dol_mktime
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
Definition: functions.lib.php:2757
llxHeader
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:59