dolibarr  13.0.2
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 Frédéric France <frederic.france@netlogic.fr>
10  * Copyright (C) 2018-2020 Charlene Benke <charlie@patas-monkey.com>
11  * Copyright (C) 2019 Nicolas ZABOURI <info@inovea-conseil.com>
12  *
13  * This program is free software; you can redistribute it and/or modify
14  * it under the terms of the GNU General Public License as published by
15  * the Free Software Foundation; either version 3 of the License, or
16  * (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program. If not, see <https://www.gnu.org/licenses/>.
25  */
26 
33 require '../../main.inc.php';
34 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
35 require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
36 require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php';
37 require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
38 require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
39 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
40 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formorder.class.php';
41 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
42 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
43 require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
44 require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
45 
46 $langs->loadLangs(array("orders", "sendings", 'deliveries', 'companies', 'compta', 'bills', 'projects', 'suppliers', 'products'));
47 
48 $action = GETPOST('action', 'aZ09');
49 $massaction = GETPOST('massaction', 'alpha');
50 $show_files = GETPOST('show_files', 'int');
51 $confirm = GETPOST('confirm', 'alpha');
52 $toselect = GETPOST('toselect', 'array');
53 $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'supplierorderlist';
54 
55 $search_orderyear = GETPOST("search_orderyear", "int");
56 $search_ordermonth = GETPOST("search_ordermonth", "int");
57 $search_orderday = GETPOST("search_orderday", "int");
58 $search_deliveryyear = GETPOST("search_deliveryyear", "int");
59 $search_deliverymonth = GETPOST("search_deliverymonth", "int");
60 $search_deliveryday = GETPOST("search_deliveryday", "int");
61 
62 $sall = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml'));
63 
64 $search_product_category = GETPOST('search_product_category', 'int');
65 $search_ref = GETPOST('search_ref', 'alpha');
66 $search_refsupp = GETPOST('search_refsupp', 'alpha');
67 $search_company = GETPOST('search_company', 'alpha');
68 $search_town = GETPOST('search_town', 'alpha');
69 $search_zip = GETPOST('search_zip', 'alpha');
70 $search_state = GETPOST("search_state", 'alpha');
71 $search_country = GETPOST("search_country", 'int');
72 $search_type_thirdparty = GETPOST("search_type_thirdparty", 'int');
73 $search_user = GETPOST('search_user', 'int');
74 $search_request_author = GETPOST('search_request_author', 'alpha');
75 $search_ht = GETPOST('search_ht', 'alpha');
76 $search_ttc = GETPOST('search_ttc', 'alpha');
77 $optioncss = GETPOST('optioncss', 'alpha');
78 $socid = GETPOST('socid', 'int');
79 $search_sale = GETPOST('search_sale', 'int');
80 $search_total_ht = GETPOST('search_total_ht', 'alpha');
81 $search_total_vat = GETPOST('search_total_vat', 'alpha');
82 $search_total_ttc = GETPOST('search_total_ttc', 'alpha');
83 $search_multicurrency_code = GETPOST('search_multicurrency_code', 'alpha');
84 $search_multicurrency_tx = GETPOST('search_multicurrency_tx', 'alpha');
85 $search_multicurrency_montant_ht = GETPOST('search_multicurrency_montant_ht', 'alpha');
86 $search_multicurrency_montant_vat = GETPOST('search_multicurrency_montant_vat', 'alpha');
87 $search_multicurrency_montant_ttc = GETPOST('search_multicurrency_montant_ttc', 'alpha');
88 $optioncss = GETPOST('optioncss', 'alpha');
89 $search_billed = GETPOST('search_billed', 'int');
90 $search_project_ref = GETPOST('search_project_ref', 'alpha');
91 $search_btn = GETPOST('button_search', 'alpha');
92 $search_remove_btn = GETPOST('button_removefilter', 'alpha');
93 
94 if (is_array(GETPOST('search_status', 'intcomma'))) {
95  $search_status = join(',', GETPOST('search_status', 'intcomma'));
96 } else {
97  $search_status = (GETPOST('search_status', 'intcomma') != '' ? GETPOST('search_status', 'intcomma') : GETPOST('statut', 'intcomma'));
98 }
99 
100 // Security check
101 $orderid = GETPOST('orderid', 'int');
102 if ($user->socid) $socid = $user->socid;
103 $result = restrictedArea($user, 'fournisseur', $orderid, '', 'commande');
104 
105 $diroutputmassaction = $conf->fournisseur->commande->dir_output.'/temp/massgeneration/'.$user->id;
106 
107 $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
108 $sortfield = GETPOST("sortfield", 'alpha');
109 $sortorder = GETPOST("sortorder", 'alpha');
110 $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : 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 $pageprev = $page - 1;
114 $pagenext = $page + 1;
115 if (!$sortfield) $sortfield = 'cf.ref';
116 if (!$sortorder) $sortorder = 'DESC';
117 
118 if ($search_status == '') $search_status = -1;
119 
120 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
121 $object = new CommandeFournisseur($db);
122 $hookmanager->initHooks(array('supplierorderlist'));
123 $extrafields = new ExtraFields($db);
124 
125 // fetch optionals attributes and labels
126 $extrafields->fetch_name_optionals_label($object->table_element);
127 
128 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
129 
130 // List of fields to search into when doing a "search in all"
131 $fieldstosearchall = array(
132  'cf.ref'=>'Ref',
133  'cf.ref_supplier'=>'RefOrderSupplier',
134  'pd.description'=>'Description',
135  's.nom'=>"ThirdParty",
136  's.name_alias'=>"AliasNameShort",
137  's.zip'=>"Zip",
138  's.town'=>"Town",
139  'cf.note_public'=>'NotePublic',
140 );
141 if (empty($user->socid)) $fieldstosearchall["cf.note_private"] = "NotePrivate";
142 
143 $checkedtypetiers = 0;
144 $arrayfields = array(
145  'cf.ref'=>array('label'=>"Ref", 'checked'=>1),
146  'cf.ref_supplier'=>array('label'=>"RefOrderSupplierShort", 'checked'=>1, 'enabled'=>1),
147  'p.project_ref'=>array('label'=>"ProjectRef", 'checked'=>0, 'enabled'=>1),
148  'u.login'=>array('label'=>"AuthorRequest", 'checked'=>1),
149  's.nom'=>array('label'=>"ThirdParty", 'checked'=>1),
150  's.town'=>array('label'=>"Town", 'checked'=>1),
151  's.zip'=>array('label'=>"Zip", 'checked'=>1),
152  'state.nom'=>array('label'=>"StateShort", 'checked'=>0),
153  'country.code_iso'=>array('label'=>"Country", 'checked'=>0),
154  'typent.code'=>array('label'=>"ThirdPartyType", 'checked'=>$checkedtypetiers),
155  'cf.date_commande'=>array('label'=>"OrderDateShort", 'checked'=>1),
156  'cf.date_livraison'=>array('label'=>"DateDeliveryPlanned", 'checked'=>1, 'enabled'=>empty($conf->global->ORDER_DISABLE_DELIVERY_DATE)),
157  'cf.total_ht'=>array('label'=>"AmountHT", 'checked'=>1),
158  'cf.total_vat'=>array('label'=>"AmountVAT", 'checked'=>0),
159  'cf.total_ttc'=>array('label'=>"AmountTTC", 'checked'=>0),
160  'cf.multicurrency_code'=>array('label'=>'Currency', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)),
161  'cf.multicurrency_tx'=>array('label'=>'CurrencyRate', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)),
162  'cf.multicurrency_total_ht'=>array('label'=>'MulticurrencyAmountHT', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)),
163  'cf.multicurrency_total_vat'=>array('label'=>'MulticurrencyAmountVAT', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)),
164  'cf.multicurrency_total_ttc'=>array('label'=>'MulticurrencyAmountTTC', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)),
165  'cf.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>500),
166  'cf.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>500),
167  'cf.fk_statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000),
168  'cf.billed'=>array('label'=>"Billed", 'checked'=>1, 'position'=>1000, 'enabled'=>1)
169 );
170 // Extra fields
171 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
172 
173 $object->fields = dol_sort_array($object->fields, 'position');
174 $arrayfields = dol_sort_array($arrayfields, 'position');
175 
176 $error = 0;
177 
178 
179 /*
180  * Actions
181  */
182 
183 if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; }
184 if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createsupplierbills') { $massaction = ''; }
185 
186 $parameters = array('socid'=>$socid);
187 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
188 if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
189 
190 if (empty($reshook))
191 {
192  // Selection of new fields
193  include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
194 
195  // Purge search criteria
196  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
197  {
198  $search_categ = '';
199  $search_user = '';
200  $search_sale = '';
201  $search_product_category = '';
202  $search_ref = '';
203  $search_refsupp = '';
204  $search_company = '';
205  $search_town = '';
206  $search_zip = "";
207  $search_state = "";
208  $search_type = '';
209  $search_country = '';
210  $search_type_thirdparty = '';
211  $search_request_author = '';
212  $search_total_ht = '';
213  $search_total_vat = '';
214  $search_total_ttc = '';
215  $search_multicurrency_code = '';
216  $search_multicurrency_tx = '';
217  $search_multicurrency_montant_ht = '';
218  $search_multicurrency_montant_vat = '';
219  $search_multicurrency_montant_ttc = '';
220  $search_project_ref = '';
221  $search_status = -1;
222  $search_orderyear = '';
223  $search_ordermonth = '';
224  $search_orderday = '';
225  $search_deliveryday = '';
226  $search_deliverymonth = '';
227  $search_deliveryyear = '';
228  $billed = '';
229  $search_billed = '';
230  $toselect = '';
231  $search_array_options = array();
232  }
233  if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')
234  || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha'))
235  {
236  $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation
237  }
238 
239  // Mass actions
240  $objectclass = 'CommandeFournisseur';
241  $objectlabel = 'SupplierOrders';
242  $permissiontoread = $user->rights->fournisseur->commande->lire;
243  $permissiontodelete = $user->rights->fournisseur->commande->supprimer;
244  $uploaddir = $conf->fournisseur->commande->dir_output;
245  include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
246 
247  // TODO Move this into mass action include
248  if ($massaction == 'confirm_createsupplierbills')
249  {
250  $orders = GETPOST('toselect', 'array');
251  $createbills_onebythird = GETPOST('createbills_onebythird', 'int');
252  $validate_invoices = GETPOST('validate_invoices', 'int');
253 
254  $TFact = array();
255  $TFactThird = array();
256 
257  $nb_bills_created = 0;
258 
259  $db->begin();
260 
261  foreach ($orders as $id_order) {
262  $cmd = new CommandeFournisseur($db);
263  if ($cmd->fetch($id_order) <= 0) continue;
264 
265  $objecttmp = new FactureFournisseur($db);
266  if (!empty($createbills_onebythird) && !empty($TFactThird[$cmd->socid])) $objecttmp = $TFactThird[$cmd->socid]; // If option "one bill per third" is set, we use already created order.
267  else {
268  $objecttmp->socid = $cmd->socid;
269  $objecttmp->type = $objecttmp::TYPE_STANDARD;
270  $objecttmp->cond_reglement_id = $cmd->cond_reglement_id;
271  $objecttmp->mode_reglement_id = $cmd->mode_reglement_id;
272  $objecttmp->fk_project = $cmd->fk_project;
273  $objecttmp->multicurrency_code = $cmd->multicurrency_code;
274  if (empty($createbills_onebythird)) $objecttmp->ref_client = $cmd->ref_client;
275 
276  $datefacture = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int'));
277  if (empty($datefacture))
278  {
279  $datefacture = dol_now();
280  }
281 
282  $objecttmp->date = $datefacture;
283  $objecttmp->origin = 'order_supplier';
284  $objecttmp->origin_id = $id_order;
285 
286  $res = $objecttmp->create($user);
287 
288  if ($res > 0) $nb_bills_created++;
289  }
290 
291  if ($objecttmp->id > 0)
292  {
293  $sql = "INSERT INTO ".MAIN_DB_PREFIX."element_element (";
294  $sql .= "fk_source";
295  $sql .= ", sourcetype";
296  $sql .= ", fk_target";
297  $sql .= ", targettype";
298  $sql .= ") VALUES (";
299  $sql .= $id_order;
300  $sql .= ", '".$db->escape($objecttmp->origin)."'";
301  $sql .= ", ".$objecttmp->id;
302  $sql .= ", '".$db->escape($objecttmp->element)."'";
303  $sql .= ")";
304 
305  if (!$db->query($sql))
306  {
307  $erorr++;
308  }
309 
310  if (!$error)
311  {
312  $lines = $cmd->lines;
313  if (empty($lines) && method_exists($cmd, 'fetch_lines'))
314  {
315  $cmd->fetch_lines();
316  $lines = $cmd->lines;
317  }
318 
319  $fk_parent_line = 0;
320  $num = count($lines);
321 
322  for ($i = 0; $i < $num; $i++)
323  {
324  $desc = ($lines[$i]->desc ? $lines[$i]->desc : $lines[$i]->libelle);
325  if ($lines[$i]->subprice < 0)
326  {
327  // Negative line, we create a discount line
328  $discount = new DiscountAbsolute($db);
329  $discount->fk_soc = $objecttmp->socid;
330  $discount->amount_ht = abs($lines[$i]->total_ht);
331  $discount->amount_tva = abs($lines[$i]->total_tva);
332  $discount->amount_ttc = abs($lines[$i]->total_ttc);
333  $discount->tva_tx = $lines[$i]->tva_tx;
334  $discount->fk_user = $user->id;
335  $discount->description = $desc;
336  $discountid = $discount->create($user);
337  if ($discountid > 0)
338  {
339  $result = $objecttmp->insert_discount($discountid);
340  //$result=$discount->link_to_invoice($lineid,$id);
341  } else {
342  setEventMessages($discount->error, $discount->errors, 'errors');
343  $error++;
344  break;
345  }
346  } else {
347  // Positive line
348  $product_type = ($lines[$i]->product_type ? $lines[$i]->product_type : 0);
349  // Date start
350  $date_start = false;
351  if ($lines[$i]->date_debut_prevue) $date_start = $lines[$i]->date_debut_prevue;
352  if ($lines[$i]->date_debut_reel) $date_start = $lines[$i]->date_debut_reel;
353  if ($lines[$i]->date_start) $date_start = $lines[$i]->date_start;
354  //Date end
355  $date_end = false;
356  if ($lines[$i]->date_fin_prevue) $date_end = $lines[$i]->date_fin_prevue;
357  if ($lines[$i]->date_fin_reel) $date_end = $lines[$i]->date_fin_reel;
358  if ($lines[$i]->date_end) $date_end = $lines[$i]->date_end;
359  // Reset fk_parent_line for no child products and special product
360  if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9)
361  {
362  $fk_parent_line = 0;
363  }
364  $result = $objecttmp->addline(
365  $desc,
366  $lines[$i]->subprice,
367  $lines[$i]->tva_tx,
368  $lines[$i]->localtax1_tx,
369  $lines[$i]->localtax2_tx,
370  $lines[$i]->qty,
371  $lines[$i]->fk_product,
372  $lines[$i]->remise_percent,
373  $date_start,
374  $date_end,
375  0,
376  $lines[$i]->info_bits,
377  'HT',
378  $product_type,
379  $lines[$i]->rang,
380  false,
381  $lines[$i]->array_options,
382  $lines[$i]->fk_unit,
383  $objecttmp->origin_id,
384  $lines[$i]->pa_ht,
385  $lines[$i]->ref_supplier,
386  $lines[$i]->special_code,
387  $fk_parent_line
388  );
389  if ($result > 0)
390  {
391  $lineid = $result;
392  } else {
393  $lineid = 0;
394  $error++;
395  break;
396  }
397  // Defined the new fk_parent_line
398  if ($result > 0 && $lines[$i]->product_type == 9)
399  {
400  $fk_parent_line = $result;
401  }
402  }
403  }
404  }
405  }
406 
407  $cmd->classifyBilled($user); // TODO Move this in workflow like done for customer orders
408 
409  if (!empty($createbills_onebythird) && empty($TFactThird[$cmd->socid])) $TFactThird[$cmd->socid] = $objecttmp;
410  else $TFact[$objecttmp->id] = $objecttmp;
411  }
412 
413  // Build doc with all invoices
414  $TAllFact = empty($createbills_onebythird) ? $TFact : $TFactThird;
415  $toselect = array();
416 
417  if (!$error && $validate_invoices) {
418  $massaction = $action = 'builddoc';
419 
420  foreach ($TAllFact as &$objecttmp)
421  {
422  $objecttmp->validate($user);
423  if ($result <= 0)
424  {
425  $error++;
426  setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
427  break;
428  }
429 
430  $id = $objecttmp->id; // For builddoc action
431 
432  // Fac builddoc
433  $donotredirect = 1;
434  $upload_dir = $conf->fournisseur->facture->dir_output;
435  $permissiontoadd = $user->rights->fournisseur->facture->creer;
436  //include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
437  }
438 
439  $massaction = $action = 'confirm_createsupplierbills';
440  }
441 
442  if (!$error)
443  {
444  $db->commit();
445  setEventMessages($langs->trans('BillCreated', $nb_bills_created), null, 'mesgs');
446 
447  // Make a redirect to avoid to bill twice if we make a refresh or back
448  $param = '';
449  if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
450  if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
451  if ($sall) $param .= '&sall='.urlencode($sall);
452  if ($socid > 0) $param .= '&socid='.urlencode($socid);
453  if ($search_status != '') $param .= '&search_status='.urlencode($search_status);
454  if ($search_orderday) $param .= '&search_orderday='.urlencode($search_orderday);
455  if ($search_ordermonth) $param .= '&search_ordermonth='.urlencode($search_ordermonth);
456  if ($search_orderyear) $param .= '&search_orderyear='.urlencode($search_orderyear);
457  if ($search_deliveryday) $param .= '&search_deliveryday='.urlencode($search_deliveryday);
458  if ($search_deliverymonth) $param .= '&search_deliverymonth='.urlencode($search_deliverymonth);
459  if ($search_deliveryyear) $param .= '&search_deliveryyear='.urlencode($search_deliveryyear);
460  if ($search_ref) $param .= '&search_ref='.urlencode($search_ref);
461  if ($search_company) $param .= '&search_company='.urlencode($search_company);
462  if ($search_ref_customer) $param .= '&search_ref_customer='.urlencode($search_ref_customer);
463  if ($search_user > 0) $param .= '&search_user='.urlencode($search_user);
464  if ($search_sale > 0) $param .= '&search_sale='.urlencode($search_sale);
465  if ($search_total_ht != '') $param .= '&search_total_ht='.urlencode($search_total_ht);
466  if ($search_total_vat != '') $param .= '&search_total_vat='.urlencode($search_total_vat);
467  if ($search_total_ttc != '') $param .= '&search_total_ttc='.urlencode($search_total_ttc);
468  if ($search_project_ref >= 0) $param .= "&search_project_ref=".urlencode($search_project_ref);
469  if ($show_files) $param .= '&show_files='.urlencode($show_files);
470  if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss);
471  if ($billed != '') $param .= '&billed='.urlencode($billed);
472 
473  header("Location: ".$_SERVER['PHP_SELF'].'?'.$param);
474  exit;
475  } else {
476  $db->rollback();
477  $action = 'create';
478  $_GET["origin"] = $_POST["origin"];
479  $_GET["originid"] = $_POST["originid"];
480  setEventMessages("Error", null, 'errors');
481  $error++;
482  }
483  }
484 }
485 
486 
487 /*
488  * View
489  */
490 
491 $now = dol_now();
492 
493 $form = new Form($db);
494 $thirdpartytmp = new Fournisseur($db);
495 $commandestatic = new CommandeFournisseur($db);
496 $formfile = new FormFile($db);
497 $formorder = new FormOrder($db);
498 $formother = new FormOther($db);
499 $formcompany = new FormCompany($db);
500 
501 $title = $langs->trans("ListOfSupplierOrders");
502 if ($socid > 0)
503 {
504  $fourn = new Fournisseur($db);
505  $fourn->fetch($socid);
506  $title .= ' - '.$fourn->name;
507 }
508 
509 /*if ($search_status)
510 {
511  if ($search_status == '1,2') $title .= ' - '.$langs->trans("SuppliersOrdersToProcess");
512  elseif ($search_status == '3,4') $title .= ' - '.$langs->trans("SuppliersOrdersAwaitingReception");
513  elseif ($search_status == '1,2,3') $title .= ' - '.$langs->trans("StatusOrderToProcessShort");
514  elseif ($search_status == '6,7') $title .= ' - '.$langs->trans("StatusOrderCanceled");
515  elseif (is_numeric($search_status) && $search_status >= 0) $title .= ' - '.$commandestatic->LibStatut($search_status);
516 }*/
517 if ($search_billed > 0) $title .= ' - '.$langs->trans("Billed");
518 
519 //$help_url="EN:Module_Customers_Orders|FR:Module_Commandes_Clients|ES:Módulo_Pedidos_de_clientes";
520 $help_url = '';
521 // llxHeader('',$title,$help_url);
522 
523 $sql = 'SELECT';
524 if ($sall || $search_product_category > 0 || $search_user > 0) $sql = 'SELECT DISTINCT';
525 $sql .= ' s.rowid as socid, s.nom as name, s.town, s.zip, s.fk_pays, s.client, s.code_client, s.email,';
526 $sql .= " typent.code as typent_code,";
527 $sql .= " state.code_departement as state_code, state.nom as state_name,";
528 $sql .= " cf.rowid, cf.ref, cf.ref_supplier, cf.fk_statut, cf.billed, cf.total_ht, cf.tva as total_tva, cf.total_ttc, cf.fk_user_author, cf.date_commande as date_commande, cf.date_livraison as date_livraison,";
529 $sql .= ' cf.fk_multicurrency, cf.multicurrency_code, cf.multicurrency_tx, cf.multicurrency_total_ht, cf.multicurrency_total_tva as multicurrency_total_vat, cf.multicurrency_total_ttc,';
530 $sql .= ' cf.date_creation as date_creation, cf.tms as date_update,';
531 $sql .= ' cf.note_public, cf.note_private,';
532 $sql .= " p.rowid as project_id, p.ref as project_ref, p.title as project_title,";
533 $sql .= " u.firstname, u.lastname, u.photo, u.login, u.email as user_email";
534 // Add fields from extrafields
535 if (!empty($extrafields->attributes[$object->table_element]['label'])) {
536  foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : '');
537 }
538 // Add fields from hooks
539 $parameters = array();
540 $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook
541 $sql .= $hookmanager->resPrint;
542 $sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
543 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays)";
544 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typent)";
545 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)";
546 $sql .= ", ".MAIN_DB_PREFIX."commande_fournisseur as cf";
547 if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (cf.rowid = ef.fk_object)";
548 if ($sall || $search_product_category > 0) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'commande_fournisseurdet as pd ON cf.rowid=pd.fk_commande';
549 if ($search_product_category > 0) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product=pd.fk_product';
550 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON cf.fk_user_author = u.rowid";
551 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = cf.fk_projet";
552 // We'll need this table joined to the select in order to filter by sale
553 if ($search_sale > 0 || (!$user->rights->societe->client->voir && !$socid)) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
554 if ($search_user > 0)
555 {
556  $sql .= ", ".MAIN_DB_PREFIX."element_contact as ec";
557  $sql .= ", ".MAIN_DB_PREFIX."c_type_contact as tc";
558 }
559 $parameters = array();
560 $reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object); // Note that $action and $object may have been modified by hook
561 $sql .= $hookmanager->resPrint;
562 $sql .= ' WHERE cf.fk_soc = s.rowid';
563 $sql .= ' AND cf.entity IN ('.getEntity('supplier_order').')';
564 if ($socid > 0) $sql .= " AND s.rowid = ".$socid;
565 if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
566 if ($search_ref) $sql .= natural_search('cf.ref', $search_ref);
567 if ($search_refsupp) $sql .= natural_search("cf.ref_supplier", $search_refsupp);
568 if ($sall) $sql .= natural_search(array_keys($fieldstosearchall), $sall);
569 if ($search_company) $sql .= natural_search('s.nom', $search_company);
570 if ($search_request_author) $sql .= natural_search(array('u.lastname', 'u.firstname', 'u.login'), $search_request_author);
571 if ($search_billed != '' && $search_billed >= 0) $sql .= " AND cf.billed = ".$db->escape($search_billed);
572 if ($search_product_category > 0) $sql .= " AND cp.fk_categorie = ".$search_product_category;
573 //Required triple check because statut=0 means draft filter
574 if (GETPOST('statut', 'intcomma') !== '')
575  $sql .= " AND cf.fk_statut IN (".$db->sanitize($db->escape($db->escape(GETPOST('statut', 'intcomma')))).")";
576 if ($search_status != '' && $search_status != '-1')
577  $sql .= " AND cf.fk_statut IN (".$db->sanitize($db->escape($search_status)).")";
578 $sql .= dolSqlDateFilter("cf.date_commande", $search_orderday, $search_ordermonth, $search_orderyear);
579 $sql .= dolSqlDateFilter("cf.date_livraison", $search_deliveryday, $search_deliverymonth, $search_deliveryyear);
580 if ($search_town) $sql .= natural_search('s.town', $search_town);
581 if ($search_zip) $sql .= natural_search("s.zip", $search_zip);
582 if ($search_state) $sql .= natural_search("state.nom", $search_state);
583 if ($search_country) $sql .= " AND s.fk_pays IN (".$db->sanitize($db->escape($search_country)).')';
584 if ($search_type_thirdparty) $sql .= " AND s.fk_typent IN (".$db->sanitize($db->escape($search_type_thirdparty)).')';
585 if ($search_company) $sql .= natural_search('s.nom', $search_company);
586 if ($search_sale > 0) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$db->escape($search_sale);
587 if ($search_user > 0) $sql .= " AND ec.fk_c_type_contact = tc.rowid AND tc.element='supplier_order' AND tc.source='internal' AND ec.element_id = cf.rowid AND ec.fk_socpeople = ".$db->escape($search_user);
588 if ($search_total_ht != '') $sql .= natural_search('cf.total_ht', $search_total_ht, 1);
589 if ($search_total_vat != '') $sql .= natural_search('cf.tva', $search_total_vat, 1);
590 if ($search_total_ttc != '') $sql .= natural_search('cf.total_ttc', $search_total_ttc, 1);
591 if ($search_multicurrency_code != '') $sql .= ' AND cf.multicurrency_code = "'.$db->escape($search_multicurrency_code).'"';
592 if ($search_multicurrency_tx != '') $sql .= natural_search('cf.multicurrency_tx', $search_multicurrency_tx, 1);
593 if ($search_multicurrency_montant_ht != '') $sql .= natural_search('cf.multicurrency_total_ht', $search_multicurrency_montant_ht, 1);
594 if ($search_multicurrency_montant_vat != '') $sql .= natural_search('cf.multicurrency_total_tva', $search_multicurrency_montant_vat, 1);
595 if ($search_multicurrency_montant_ttc != '') $sql .= natural_search('cf.multicurrency_total_ttc', $search_multicurrency_montant_ttc, 1);
596 if ($search_project_ref != '') $sql .= natural_search("p.ref", $search_project_ref);
597 // Add where from extra fields
598 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
599 // Add where from hooks
600 $parameters = array();
601 $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook
602 $sql .= $hookmanager->resPrint;
603 
604 $sql .= $db->order($sortfield, $sortorder);
605 
606 // Count total nb of records
607 $nbtotalofrecords = '';
608 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
609 {
610  $result = $db->query($sql);
611  $nbtotalofrecords = $db->num_rows($result);
612  if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0
613  {
614  $page = 0;
615  $offset = 0;
616  }
617 }
618 
619 $sql .= $db->plimit($limit + 1, $offset);
620 //print $sql;
621 
622 $resql = $db->query($sql);
623 if ($resql)
624 {
625  $num = $db->num_rows($resql);
626 
627  $arrayofselected = is_array($toselect) ? $toselect : array();
628 
629  if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $sall)
630  {
631  $obj = $db->fetch_object($resql);
632  $id = $obj->rowid;
633  header("Location: ".DOL_URL_ROOT.'/fourn/commande/card.php?id='.$id);
634  exit;
635  }
636 
637  llxHeader('', $title, $help_url);
638 
639  $param = '';
640  if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
641  if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
642  if ($sall) $param .= '&sall='.urlencode($sall);
643  if ($socid > 0) $param .= '&socid='.urlencode($socid);
644  if ($sall) $param .= "&search_all=".urlencode($sall);
645  if ($search_orderday) $param .= '&search_orderday='.urlencode($search_orderday);
646  if ($search_ordermonth) $param .= '&search_ordermonth='.urlencode($search_ordermonth);
647  if ($search_orderyear) $param .= '&search_orderyear='.urlencode($search_orderyear);
648  if ($search_deliveryday) $param .= '&search_deliveryday='.urlencode($search_deliveryday);
649  if ($search_deliverymonth) $param .= '&search_deliverymonth='.urlencode($search_deliverymonth);
650  if ($search_deliveryyear) $param .= '&search_deliveryyear='.urlencode($search_deliveryyear);
651  if ($search_ref) $param .= '&search_ref='.urlencode($search_ref);
652  if ($search_company) $param .= '&search_company='.urlencode($search_company);
653  if ($search_user > 0) $param .= '&search_user='.urlencode($search_user);
654  if ($search_request_author) $param .= '&search_request_author='.urlencode($search_request_author);
655  if ($search_sale > 0) $param .= '&search_sale='.urlencode($search_sale);
656  if ($search_total_ht != '') $param .= '&search_total_ht='.urlencode($search_total_ht);
657  if ($search_total_ttc != '') $param .= "&search_total_ttc=".urlencode($search_total_ttc);
658  if ($search_multicurrency_code != '') $param .= '&search_multicurrency_code='.urlencode($search_multicurrency_code);
659  if ($search_multicurrency_tx != '') $param .= '&search_multicurrency_tx='.urlencode($search_multicurrency_tx);
660  if ($search_multicurrency_montant_ht != '') $param .= '&search_multicurrency_montant_ht='.urlencode($search_multicurrency_montant_ht);
661  if ($search_multicurrency_montant_vat != '') $param .= '&search_multicurrency_montant_vat='.urlencode($search_multicurrency_montant_vat);
662  if ($search_multicurrency_montant_ttc != '') $param .= '&search_multicurrency_montant_ttc='.urlencode($search_multicurrency_montant_ttc);
663  if ($search_refsupp) $param .= "&search_refsupp=".urlencode($search_refsupp);
664  if ($search_status != '' && $search_status != '-1') $param .= "&search_status=".urlencode($search_status);
665  if ($search_project_ref >= 0) $param .= "&search_project_ref=".urlencode($search_project_ref);
666  if ($search_billed != '') $param .= "&search_billed=".urlencode($search_billed);
667  if ($show_files) $param .= '&show_files='.urlencode($show_files);
668  if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss);
669  // Add $param from extra fields
670  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
671 
672  $parameters = array();
673  $reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object); // Note that $action and $object may have been modified by hook
674  $param .= $hookmanager->resPrint;
675 
676  // List of mass actions available
677  $arrayofmassactions = array(
678  'generate_doc'=>$langs->trans("ReGeneratePDF"),
679  'builddoc'=>$langs->trans("PDFMerge"),
680  'presend'=>$langs->trans("SendByMail"),
681  );
682  if ($user->rights->fournisseur->facture->creer) $arrayofmassactions['createbills'] = $langs->trans("CreateInvoiceForThisSupplier");
683  if ($user->rights->fournisseur->commande->supprimer) $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
684  if (in_array($massaction, array('presend', 'predelete', 'createbills'))) $arrayofmassactions = array();
685  $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
686 
687  $url = DOL_URL_ROOT.'/fourn/commande/card.php?action=create';
688  if (!empty($socid)) $url .= '&socid='.$socid;
689  $newcardbutton = dolGetButtonTitle($langs->trans('NewOrder'), '', 'fa fa-plus-circle', $url, '', $user->rights->fournisseur->commande->creer);
690 
691  // Lines of title fields
692  print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
693  if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
694  print '<input type="hidden" name="token" value="'.newToken().'">';
695  print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
696  print '<input type="hidden" name="action" value="list">';
697  print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
698  print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
699  print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
700  print '<input type="hidden" name="socid" value="'.$socid.'">';
701 
702  print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'supplier_order', 0, $newcardbutton, '', $limit, 0, 0, 1);
703 
704  $topicmail = "SendOrderRef";
705  $modelmail = "order_supplier_send";
706  $objecttmp = new CommandeFournisseur($db);
707  $trackid = 'sord'.$object->id;
708  include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
709 
710  if ($massaction == 'createbills')
711  {
712  //var_dump($_REQUEST);
713  print '<input type="hidden" name="massaction" value="confirm_createsupplierbills">';
714 
715  print '<table class="noborder" width="100%" >';
716  print '<tr>';
717  print '<td class="titlefield">';
718  print $langs->trans('DateInvoice');
719  print '</td>';
720  print '<td>';
721  print $form->selectDate('', '', '', '', '', '', 1, 1);
722  print '</td>';
723  print '</tr>';
724  print '<tr>';
725  print '<td>';
726  print $langs->trans('CreateOneBillByThird');
727  print '</td>';
728  print '<td>';
729  print $form->selectyesno('createbills_onebythird', '', 1);
730  print '</td>';
731  print '</tr>';
732  print '<tr>';
733  print '<td>';
734  print $langs->trans('ValidateInvoices');
735  print '</td>';
736  print '<td>';
737  print $form->selectyesno('validate_invoices', 1, 1);
738  print '</td>';
739  print '</tr>';
740  print '</table>';
741 
742  print '<br>';
743  print '<div class="center">';
744  print '<input type="submit" class="button" id="createbills" name="createbills" value="'.$langs->trans('CreateInvoiceForThisCustomer').'"> ';
745  print '<input type="submit" class="button button-cancel" id="cancel" name="cancel" value="'.$langs->trans("Cancel").'">';
746  print '</div>';
747  print '<br>';
748  }
749 
750  if ($sall)
751  {
752  foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val);
753  print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'</div>';
754  }
755 
756  $moreforfilter = '';
757 
758  // If the user can view prospects other than his'
759  if ($user->rights->societe->client->voir || $socid)
760  {
761  $langs->load("commercial");
762  $moreforfilter .= '<div class="divsearchfield">';
763  $moreforfilter .= $langs->trans('ThirdPartiesOfSaleRepresentative').': ';
764  $moreforfilter .= $formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, 1, 'maxwidth200');
765  $moreforfilter .= '</div>';
766  }
767  // If the user can view other users
768  if ($user->rights->user->user->lire)
769  {
770  $moreforfilter .= '<div class="divsearchfield">';
771  $moreforfilter .= $langs->trans('LinkedToSpecificUsers').': ';
772  $moreforfilter .= $form->select_dolusers($search_user, 'search_user', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth200');
773  $moreforfilter .= '</div>';
774  }
775  // If the user can view prospects other than his'
776  if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire && ($user->rights->produit->lire || $user->rights->service->lire))
777  {
778  include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
779  $moreforfilter .= '<div class="divsearchfield">';
780  $moreforfilter .= $langs->trans('IncludingProductWithTag').': ';
781  $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, null, 'parent', null, null, 1);
782  $moreforfilter .= $form->selectarray('search_product_category', $cate_arbo, $search_product_category, 1, 0, 0, '', 0, 0, 0, 0, 'maxwidth300', 1);
783  $moreforfilter .= '</div>';
784  }
785  $parameters = array();
786  $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook
787  if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint;
788  else $moreforfilter = $hookmanager->resPrint;
789 
790  if (!empty($moreforfilter))
791  {
792  print '<div class="liste_titre liste_titre_bydiv centpercent">';
793  print $moreforfilter;
794  print '</div>';
795  }
796 
797  $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
798  $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
799  $selectedfields .= $form->showCheckAddButtons('checkforselect', 1);
800 
801  if (GETPOST('autoselectall', 'int')) {
802  $selectedfields .= '<script>';
803  $selectedfields .= ' $(document).ready(function() {';
804  $selectedfields .= ' console.log("Autoclick on checkforselects");';
805  $selectedfields .= ' $("#checkforselects").click();';
806  $selectedfields .= ' $("#massaction").val("createbills").change();';
807  $selectedfields .= ' });';
808  $selectedfields .= '</script>';
809  }
810 
811  print '<div class="div-table-responsive">';
812  print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
813 
814  print '<tr class="liste_titre_filter">';
815  // Ref
816  if (!empty($arrayfields['cf.ref']['checked']))
817  {
818  print '<td class="liste_titre"><input size="8" type="text" class="flat maxwidth75" name="search_ref" value="'.$search_ref.'"></td>';
819  }
820  // Ref customer
821  if (!empty($arrayfields['cf.ref_supplier']['checked']))
822  {
823  print '<td class="liste_titre"><input type="text" class="flat maxwidth75" name="search_refsupp" value="'.$search_refsupp.'"></td>';
824  }
825  // Project ref
826  if (!empty($arrayfields['p.project_ref']['checked']))
827  {
828  print '<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_project_ref" value="'.$search_project_ref.'"></td>';
829  }
830  // Request author
831  if (!empty($arrayfields['u.login']['checked']))
832  {
833  print '<td class="liste_titre">';
834  print '<input type="text" class="flat" size="6" name="search_request_author" value="'.$search_request_author.'">';
835  print '</td>';
836  }
837  // Thirpdarty
838  if (!empty($arrayfields['s.nom']['checked']))
839  {
840  print '<td class="liste_titre"><input type="text" size="6" class="flat" name="search_company" value="'.$search_company.'"></td>';
841  }
842  // Town
843  if (!empty($arrayfields['s.town']['checked'])) print '<td class="liste_titre"><input class="flat maxwidth50" type="text" name="search_town" value="'.$search_town.'"></td>';
844  // Zip
845  if (!empty($arrayfields['s.zip']['checked'])) print '<td class="liste_titre"><input class="flat maxwidth50" type="text" name="search_zip" value="'.$search_zip.'"></td>';
846  // State
847  if (!empty($arrayfields['state.nom']['checked']))
848  {
849  print '<td class="liste_titre">';
850  print '<input class="flat maxwidth50" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).'">';
851  print '</td>';
852  }
853  // Country
854  if (!empty($arrayfields['country.code_iso']['checked']))
855  {
856  print '<td class="liste_titre center">';
857  print $form->select_country($search_country, 'search_country', '', 0, 'minwidth100imp maxwidth100');
858  print '</td>';
859  }
860  // Company type
861  if (!empty($arrayfields['typent.code']['checked']))
862  {
863  print '<td class="liste_titre maxwidthonsmartphone center">';
864  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));
865  print '</td>';
866  }
867  // Date order
868  if (!empty($arrayfields['cf.date_commande']['checked']))
869  {
870  print '<td class="liste_titre nowraponall center">';
871  if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat width25 valignmiddle" type="text" maxlength="2" name="search_orderday" value="'.$search_orderday.'">';
872  print '<input class="flat width25 valignmiddle" type="text" maxlength="2" name="search_ordermonth" value="'.$search_ordermonth.'">';
873  $formother->select_year($search_orderyear ? $search_orderyear : -1, 'search_orderyear', 1, 20, 5);
874  print '</td>';
875  }
876  // Date delivery
877  if (!empty($arrayfields['cf.date_livraison']['checked']))
878  {
879  print '<td class="liste_titre nowraponall center">';
880  if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat width25 valignmiddle" type="text" maxlength="2" name="search_deliveryday" value="'.$search_deliveryday.'">';
881  print '<input class="flat width25 valignmiddle" type="text" maxlength="2" name="search_deliverymonth" value="'.$search_deliverymonth.'">';
882  $formother->select_year($search_deliveryyear ? $search_deliveryyear : -1, 'search_deliveryyear', 1, 20, 5);
883  print '</td>';
884  }
885  if (!empty($arrayfields['cf.total_ht']['checked']))
886  {
887  // Amount
888  print '<td class="liste_titre right">';
889  print '<input class="flat" type="text" size="5" name="search_total_ht" value="'.$search_total_ht.'">';
890  print '</td>';
891  }
892  if (!empty($arrayfields['cf.total_vat']['checked']))
893  {
894  // Amount
895  print '<td class="liste_titre right">';
896  print '<input class="flat" type="text" size="5" name="search_total_vat" value="'.$search_total_vat.'">';
897  print '</td>';
898  }
899  if (!empty($arrayfields['cf.total_ttc']['checked']))
900  {
901  // Amount
902  print '<td class="liste_titre right">';
903  print '<input class="flat" type="text" size="5" name="search_total_ttc" value="'.$search_total_ttc.'">';
904  print '</td>';
905  }
906  if (!empty($arrayfields['cf.multicurrency_code']['checked']))
907  {
908  // Currency
909  print '<td class="liste_titre">';
910  print $form->selectMultiCurrency($search_multicurrency_code, 'search_multicurrency_code', 1);
911  print '</td>';
912  }
913  if (!empty($arrayfields['cf.multicurrency_tx']['checked']))
914  {
915  // Currency rate
916  print '<td class="liste_titre">';
917  print '<input class="flat" type="text" size="4" name="search_multicurrency_tx" value="'.dol_escape_htmltag($search_multicurrency_tx).'">';
918  print '</td>';
919  }
920  if (!empty($arrayfields['cf.multicurrency_total_ht']['checked']))
921  {
922  // Amount
923  print '<td class="liste_titre right">';
924  print '<input class="flat" type="text" size="4" name="search_multicurrency_montant_ht" value="'.dol_escape_htmltag($search_multicurrency_montant_ht).'">';
925  print '</td>';
926  }
927  if (!empty($arrayfields['cf.multicurrency_total_vat']['checked']))
928  {
929  // Amount
930  print '<td class="liste_titre right">';
931  print '<input class="flat" type="text" size="4" name="search_multicurrency_montant_vat" value="'.dol_escape_htmltag($search_multicurrency_montant_vat).'">';
932  print '</td>';
933  }
934  if (!empty($arrayfields['cf.multicurrency_total_ttc']['checked']))
935  {
936  // Amount
937  print '<td class="liste_titre right">';
938  print '<input class="flat" type="text" size="4" name="search_multicurrency_montant_ttc" value="'.dol_escape_htmltag($search_multicurrency_montant_ttc).'">';
939  print '</td>';
940  }
941  // Extra fields
942  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
943 
944  // Fields from hook
945  $parameters = array('arrayfields'=>$arrayfields);
946  $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
947  print $hookmanager->resPrint;
948  // Date creation
949  if (!empty($arrayfields['cf.datec']['checked']))
950  {
951  print '<td class="liste_titre">';
952  print '</td>';
953  }
954  // Date modification
955  if (!empty($arrayfields['cf.tms']['checked']))
956  {
957  print '<td class="liste_titre">';
958  print '</td>';
959  }
960  // Status
961  if (!empty($arrayfields['cf.fk_statut']['checked']))
962  {
963  print '<td class="liste_titre right">';
964  $formorder->selectSupplierOrderStatus($search_status, 1, 'search_status');
965  print '</td>';
966  }
967  // Status billed
968  if (!empty($arrayfields['cf.billed']['checked']))
969  {
970  print '<td class="liste_titre center">';
971  print $form->selectyesno('search_billed', $search_billed, 1, 0, 1, 1);
972  print '</td>';
973  }
974  // Action column
975  print '<td class="liste_titre middle">';
976  $searchpicto = $form->showFilterButtons();
977  print $searchpicto;
978  print '</td>';
979 
980  print "</tr>\n";
981 
982  // Fields title
983  print '<tr class="liste_titre">';
984  if (!empty($arrayfields['cf.ref']['checked'])) print_liste_field_titre($arrayfields['cf.ref']['label'], $_SERVER["PHP_SELF"], "cf.ref", "", $param, '', $sortfield, $sortorder);
985  if (!empty($arrayfields['cf.ref_supplier']['checked'])) print_liste_field_titre($arrayfields['cf.ref_supplier']['label'], $_SERVER["PHP_SELF"], "cf.ref_supplier", "", $param, '', $sortfield, $sortorder, 'tdoverflowmax100imp ');
986  if (!empty($arrayfields['p.project_ref']['checked'])) print_liste_field_titre($arrayfields['p.project_ref']['label'], $_SERVER["PHP_SELF"], "p.ref", "", $param, '', $sortfield, $sortorder);
987  if (!empty($arrayfields['u.login']['checked'])) print_liste_field_titre($arrayfields['u.login']['label'], $_SERVER["PHP_SELF"], "u.login", "", $param, '', $sortfield, $sortorder);
988  if (!empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", "", $param, '', $sortfield, $sortorder);
989  if (!empty($arrayfields['s.town']['checked'])) print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], 's.town', '', $param, '', $sortfield, $sortorder);
990  if (!empty($arrayfields['s.zip']['checked'])) print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], 's.zip', '', $param, '', $sortfield, $sortorder);
991  if (!empty($arrayfields['state.nom']['checked'])) print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder);
992  if (!empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, '', $sortfield, $sortorder, 'center ');
993  if (!empty($arrayfields['typent.code']['checked'])) print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, '', $sortfield, $sortorder, 'center ');
994  if (!empty($arrayfields['cf.fk_author']['checked'])) print_liste_field_titre($arrayfields['cf.fk_author']['label'], $_SERVER["PHP_SELF"], "cf.fk_author", "", $param, '', $sortfield, $sortorder);
995  if (!empty($arrayfields['cf.date_commande']['checked'])) print_liste_field_titre($arrayfields['cf.date_commande']['label'], $_SERVER["PHP_SELF"], "cf.date_commande", "", $param, '', $sortfield, $sortorder, 'center ');
996  if (!empty($arrayfields['cf.date_livraison']['checked'])) print_liste_field_titre($arrayfields['cf.date_livraison']['label'], $_SERVER["PHP_SELF"], 'cf.date_livraison', '', $param, '', $sortfield, $sortorder, 'center ');
997  if (!empty($arrayfields['cf.total_ht']['checked'])) print_liste_field_titre($arrayfields['cf.total_ht']['label'], $_SERVER["PHP_SELF"], "cf.total_ht", "", $param, '', $sortfield, $sortorder, 'right ');
998  if (!empty($arrayfields['cf.total_vat']['checked'])) print_liste_field_titre($arrayfields['cf.total_vat']['label'], $_SERVER["PHP_SELF"], "cf.tva", "", $param, '', $sortfield, $sortorder, 'right ');
999  if (!empty($arrayfields['cf.total_ttc']['checked'])) print_liste_field_titre($arrayfields['cf.total_ttc']['label'], $_SERVER["PHP_SELF"], "cf.total_ttc", "", $param, '', $sortfield, $sortorder, 'right ');
1000  if (!empty($arrayfields['cf.multicurrency_code']['checked'])) print_liste_field_titre($arrayfields['cf.multicurrency_code']['label'], $_SERVER['PHP_SELF'], 'cf.multicurrency_code', '', $param, '', $sortfield, $sortorder);
1001  if (!empty($arrayfields['cf.multicurrency_tx']['checked'])) print_liste_field_titre($arrayfields['cf.multicurrency_tx']['label'], $_SERVER['PHP_SELF'], 'cf.multicurrency_tx', '', $param, '', $sortfield, $sortorder);
1002  if (!empty($arrayfields['cf.multicurrency_total_ht']['checked'])) print_liste_field_titre($arrayfields['cf.multicurrency_total_ht']['label'], $_SERVER['PHP_SELF'], 'cf.multicurrency_total_ht', '', $param, 'class="right"', $sortfield, $sortorder);
1003  if (!empty($arrayfields['cf.multicurrency_total_vat']['checked'])) print_liste_field_titre($arrayfields['cf.multicurrency_total_vat']['label'], $_SERVER['PHP_SELF'], 'cf.multicurrency_total_tva', '', $param, 'class="right"', $sortfield, $sortorder);
1004  if (!empty($arrayfields['cf.multicurrency_total_ttc']['checked'])) print_liste_field_titre($arrayfields['cf.multicurrency_total_ttc']['label'], $_SERVER['PHP_SELF'], 'cf.multicurrency_total_ttc', '', $param, 'class="right"', $sortfield, $sortorder);
1005  // Extra fields
1006  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
1007  // Hook fields
1008  $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
1009  $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
1010  print $hookmanager->resPrint;
1011  if (!empty($arrayfields['cf.datec']['checked'])) print_liste_field_titre($arrayfields['cf.datec']['label'], $_SERVER["PHP_SELF"], "cf.date_creation", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
1012  if (!empty($arrayfields['cf.tms']['checked'])) print_liste_field_titre($arrayfields['cf.tms']['label'], $_SERVER["PHP_SELF"], "cf.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
1013  if (!empty($arrayfields['cf.fk_statut']['checked'])) print_liste_field_titre($arrayfields['cf.fk_statut']['label'], $_SERVER["PHP_SELF"], "cf.fk_statut", "", $param, '', $sortfield, $sortorder, 'right ');
1014  if (!empty($arrayfields['cf.billed']['checked'])) print_liste_field_titre($arrayfields['cf.billed']['label'], $_SERVER["PHP_SELF"], 'cf.billed', '', $param, '', $sortfield, $sortorder, 'center ');
1015  print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
1016  print "</tr>\n";
1017 
1018 
1019  $total = 0;
1020  $subtotal = 0;
1021  $productstat_cache = array();
1022 
1023  $userstatic = new User($db);
1024  $objectstatic = new CommandeFournisseur($db);
1025  $projectstatic = new Project($db);
1026 
1027  $i = 0;
1028  $totalarray = array();
1029  while ($i < min($num, $limit))
1030  {
1031  $obj = $db->fetch_object($resql);
1032 
1033  $notshippable = 0;
1034  $warning = 0;
1035  $text_info = '';
1036  $text_warning = '';
1037  $nbprod = 0;
1038 
1039  $objectstatic->id = $obj->rowid;
1040  $objectstatic->ref = $obj->ref;
1041  $objectstatic->ref_supplier = $obj->ref_supplier;
1042  $objectstatic->total_ht = $obj->total_ht;
1043  $objectstatic->total_tva = $obj->total_tva;
1044  $objectstatic->total_ttc = $obj->total_ttc;
1045  $objectstatic->date_commande = $db->jdate($obj->date_commande);
1046  $objectstatic->delivery_date = $db->jdate($obj->date_livraison);
1047  $objectstatic->note_public = $obj->note_public;
1048  $objectstatic->note_private = $obj->note_private;
1049  $objectstatic->statut = $obj->fk_statut;
1050 
1051  print '<tr class="oddeven">';
1052 
1053  // Ref
1054  if (!empty($arrayfields['cf.ref']['checked']))
1055  {
1056  print '<td class="nowrap">';
1057 
1058  // Picto + Ref
1059  print $objectstatic->getNomUrl(1, '', 0, -1, 1);
1060  // Other picto tool
1061  $filename = dol_sanitizeFileName($obj->ref);
1062  $filedir = $conf->fournisseur->commande->dir_output.'/'.dol_sanitizeFileName($obj->ref);
1063  print $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir);
1064 
1065  print '</td>'."\n";
1066  if (!$i) $totalarray['nbfield']++;
1067  }
1068  // Ref Supplier
1069  if (!empty($arrayfields['cf.ref_supplier']['checked']))
1070  {
1071  print '<td>'.$obj->ref_supplier.'</td>'."\n";
1072  if (!$i) $totalarray['nbfield']++;
1073  }
1074  // Project
1075  if (!empty($arrayfields['p.project_ref']['checked']))
1076  {
1077  $projectstatic->id = $obj->project_id;
1078  $projectstatic->ref = $obj->project_ref;
1079  $projectstatic->title = $obj->project_title;
1080  print '<td>';
1081  if ($obj->project_id > 0) print $projectstatic->getNomUrl(1);
1082  print '</td>';
1083  if (!$i) $totalarray['nbfield']++;
1084  }
1085  // Author
1086  $userstatic->id = $obj->fk_user_author;
1087  $userstatic->lastname = $obj->lastname;
1088  $userstatic->firstname = $obj->firstname;
1089  $userstatic->login = $obj->login;
1090  $userstatic->photo = $obj->photo;
1091  $userstatic->email = $obj->user_email;
1092  if (!empty($arrayfields['u.login']['checked']))
1093  {
1094  print '<td class="tdoverflowmax150">';
1095  if ($userstatic->id) print $userstatic->getNomUrl(1);
1096  print "</td>";
1097  if (!$i) $totalarray['nbfield']++;
1098  }
1099  // Thirdparty
1100  if (!empty($arrayfields['s.nom']['checked']))
1101  {
1102  print '<td class="tdoverflowmax150">';
1103  $thirdpartytmp->id = $obj->socid;
1104  $thirdpartytmp->name = $obj->name;
1105  $thirdpartytmp->email = $obj->email;
1106  print $thirdpartytmp->getNomUrl(1, 'supplier');
1107  print '</td>'."\n";
1108  if (!$i) $totalarray['nbfield']++;
1109  }
1110  // Town
1111  if (!empty($arrayfields['s.town']['checked']))
1112  {
1113  print '<td>';
1114  print $obj->town;
1115  print '</td>';
1116  if (!$i) $totalarray['nbfield']++;
1117  }
1118  // Zip
1119  if (!empty($arrayfields['s.zip']['checked']))
1120  {
1121  print '<td>';
1122  print $obj->zip;
1123  print '</td>';
1124  if (!$i) $totalarray['nbfield']++;
1125  }
1126  // State
1127  if (!empty($arrayfields['state.nom']['checked']))
1128  {
1129  print "<td>".$obj->state_name."</td>\n";
1130  if (!$i) $totalarray['nbfield']++;
1131  }
1132  // Country
1133  if (!empty($arrayfields['country.code_iso']['checked']))
1134  {
1135  print '<td class="center">';
1136  $tmparray = getCountry($obj->fk_pays, 'all');
1137  print $tmparray['label'];
1138  print '</td>';
1139  if (!$i) $totalarray['nbfield']++;
1140  }
1141  // Type ent
1142  if (!empty($arrayfields['typent.code']['checked']))
1143  {
1144  print '<td class="center">';
1145  if (count($typenArray) == 0) $typenArray = $formcompany->typent_array(1);
1146  print $typenArray[$obj->typent_code];
1147  print '</td>';
1148  if (!$i) $totalarray['nbfield']++;
1149  }
1150 
1151  // Order date
1152  if (!empty($arrayfields['cf.date_commande']['checked']))
1153  {
1154  print '<td class="center">';
1155  print dol_print_date($db->jdate($obj->date_commande), 'day');
1156  if ($objectstatic->statut != $objectstatic::STATUS_ORDERSENT && $objectstatic->statut != $objectstatic::STATUS_RECEIVED_PARTIALLY) {
1157  if ($objectstatic->hasDelay()) {
1158  print ' '.img_picto($langs->trans("Late").' : '.$objectstatic->showDelay(), "warning");
1159  }
1160  }
1161  print '</td>';
1162  if (!$i) $totalarray['nbfield']++;
1163  }
1164  // Plannned date of delivery
1165  if (!empty($arrayfields['cf.date_livraison']['checked']))
1166  {
1167  print '<td class="center">';
1168  print dol_print_date($db->jdate($obj->date_livraison), 'day');
1169  if ($objectstatic->statut == $objectstatic::STATUS_ORDERSENT || $objectstatic->statut == $objectstatic::STATUS_RECEIVED_PARTIALLY) {
1170  if ($objectstatic->hasDelay()) {
1171  print ' '.img_picto($langs->trans("Late").' : '.$objectstatic->showDelay(), "warning");
1172  }
1173  }
1174  print '</td>';
1175  if (!$i) $totalarray['nbfield']++;
1176  }
1177  // Amount HT
1178  if (!empty($arrayfields['cf.total_ht']['checked']))
1179  {
1180  print '<td class="right">'.price($obj->total_ht)."</td>\n";
1181  if (!$i) $totalarray['nbfield']++;
1182  if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'cf.total_ht';
1183  $totalarray['val']['cf.total_ht'] += $obj->total_ht;
1184  }
1185  // Amount VAT
1186  if (!empty($arrayfields['cf.total_vat']['checked']))
1187  {
1188  print '<td class="right">'.price($obj->total_tva)."</td>\n";
1189  if (!$i) $totalarray['nbfield']++;
1190  if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'cf.total_vat';
1191  $totalarray['val']['cf.total_vat'] += $obj->total_tva;
1192  }
1193  // Amount TTC
1194  if (!empty($arrayfields['cf.total_ttc']['checked']))
1195  {
1196  print '<td class="right">'.price($obj->total_ttc)."</td>\n";
1197  if (!$i) $totalarray['nbfield']++;
1198  if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'cf.total_ttc';
1199  $totalarray['val']['cf.total_ttc'] += $obj->total_ttc;
1200  }
1201 
1202  // Currency
1203  if (!empty($arrayfields['cf.multicurrency_code']['checked']))
1204  {
1205  print '<td class="nowrap">'.$obj->multicurrency_code.' - '.$langs->trans('Currency'.$obj->multicurrency_code)."</td>\n";
1206  if (!$i) $totalarray['nbfield']++;
1207  }
1208 
1209  // Currency rate
1210  if (!empty($arrayfields['cf.multicurrency_tx']['checked']))
1211  {
1212  print '<td class="nowrap">';
1213  $form->form_multicurrency_rate($_SERVER['PHP_SELF'].'?id='.$obj->rowid, $obj->multicurrency_tx, 'none', $obj->multicurrency_code);
1214  print "</td>\n";
1215  if (!$i) $totalarray['nbfield']++;
1216  }
1217  // Amount HT
1218  if (!empty($arrayfields['cf.multicurrency_total_ht']['checked']))
1219  {
1220  print '<td class="right nowrap">'.price($obj->multicurrency_total_ht)."</td>\n";
1221  if (!$i) $totalarray['nbfield']++;
1222  }
1223  // Amount VAT
1224  if (!empty($arrayfields['cf.multicurrency_total_vat']['checked']))
1225  {
1226  print '<td class="right nowrap">'.price($obj->multicurrency_total_vat)."</td>\n";
1227  if (!$i) $totalarray['nbfield']++;
1228  }
1229  // Amount TTC
1230  if (!empty($arrayfields['cf.multicurrency_total_ttc']['checked']))
1231  {
1232  print '<td class="right nowrap">'.price($obj->multicurrency_total_ttc)."</td>\n";
1233  if (!$i) $totalarray['nbfield']++;
1234  }
1235 
1236  // Extra fields
1237  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
1238  // Fields from hook
1239  $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
1240  $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook
1241  print $hookmanager->resPrint;
1242  // Date creation
1243  if (!empty($arrayfields['cf.datec']['checked']))
1244  {
1245  print '<td class="center nowrap">';
1246  print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser');
1247  print '</td>';
1248  if (!$i) $totalarray['nbfield']++;
1249  }
1250  // Date modification
1251  if (!empty($arrayfields['cf.tms']['checked']))
1252  {
1253  print '<td class="center nowrap">';
1254  print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser');
1255  print '</td>';
1256  if (!$i) $totalarray['nbfield']++;
1257  }
1258  // Status
1259  if (!empty($arrayfields['cf.fk_statut']['checked']))
1260  {
1261  print '<td class="right nowrap">'.$objectstatic->LibStatut($obj->fk_statut, 5, $obj->billed).'</td>';
1262  if (!$i) $totalarray['nbfield']++;
1263  }
1264  // Billed
1265  if (!empty($arrayfields['cf.billed']['checked']))
1266  {
1267  print '<td class="center">'.yn($obj->billed).'</td>';
1268  if (!$i) $totalarray['nbfield']++;
1269  }
1270 
1271  // Action column
1272  print '<td class="nowrap center">';
1273  if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
1274  {
1275  $selected = 0;
1276  if (in_array($obj->rowid, $arrayofselected)) $selected = 1;
1277  print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
1278  }
1279  print '</td>';
1280  if (!$i) $totalarray['nbfield']++;
1281 
1282  print "</tr>\n";
1283 
1284  $total += $obj->total_ht;
1285  $subtotal += $obj->total_ht;
1286  $i++;
1287  }
1288 
1289  // Show total line
1290  include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
1291 
1292  $db->free($resql);
1293 
1294  $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql);
1295  $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook
1296  print $hookmanager->resPrint;
1297 
1298  print '</table>'."\n";
1299  print '</div>';
1300 
1301  print '</form>'."\n";
1302 
1303  $hidegeneratedfilelistifempty = 1;
1304  if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0;
1305 
1306  // Show list of available documents
1307  $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
1308  $urlsource .= str_replace('&amp;', '&', $param);
1309 
1310  $filedir = $diroutputmassaction;
1311  $genallowed = $user->rights->fournisseur->commande->lire;
1312  $delallowed = $user->rights->fournisseur->commande->creer;
1313 
1314  print $formfile->showdocuments('massfilesarea_supplier_order', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
1315 } else {
1316  dol_print_error($db);
1317 }
1318 
1319 // End of page
1320 llxFooter();
1321 $db->close();
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
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...
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.
dol_now($mode= 'auto')
Return date for now.
Class to manage Dolibarr users.
Definition: user.class.php:44
Class to manage suppliers invoices.
Class to manage suppliers.
llxHeader()
Empty header.
Definition: wrapper.php:45
Class to build HTML component for third parties management Only common components are here...
Class to manage standard extra fields.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
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.
Class to manage generation of HTML components Only common components must be here.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname.
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
Class to manage projects.
Class to manage HTML output components for orders Before adding component here, check they are not in...
Classe permettant la generation de composants html autre Only common components are here...
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.
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_sanitizeFileName($str, $newstr= '_', $unaccent=1)
Clean a string to use it as a file name.
dolSqlDateFilter($datefield, $day_date, $month_date, $year_date, $excludefirstand=0)
Generate a SQL string to make a filter into a range (for second of date until last second of date) ...
Definition: date.lib.php:281
Class to manage predefined suppliers products.
Class to offer components to list and upload files.
print $_SERVER["PHP_SELF"]
Edit parameters.
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...
print
Draft customers invoices.
Definition: index.php:89
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
Definition: index.php:1232
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
Class to manage absolute discounts.
llxFooter()
Empty footer.
Definition: wrapper.php:59
if(!defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN'
Draft customers invoices.
getCountry($searchkey, $withcode= '', $dbtouse=0, $outputlangs= '', $entconv=1, $searchlabel= '')
Return country label, code or id from an id, code or label.