dolibarr 24.0.0-beta
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-2026 Frédéric France <frederic.france@free.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-2026 Alexandre Spangaro <alexandre@inovea-conseil.com>
13 * Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
14 * Copyright (C) 2024 William Mead <william.mead@manchenumerique.fr>
15 *
16 * This program is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License as published by
18 * the Free Software Foundation; either version 3 of the License, or
19 * (at your option) any later version.
20 *
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
25 *
26 * You should have received a copy of the GNU General Public License
27 * along with this program. If not, see <https://www.gnu.org/licenses/>.
28 */
29
37// Load Dolibarr environment
38require '../../main.inc.php';
39
50require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
51require_once DOL_DOCUMENT_ROOT.'/core/class/html.formorder.class.php';
52require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
53require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
54require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php';
55require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
56require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
57require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php';
58require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
59require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
60require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
61require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
62
63// Load translation files required by the page
64$langs->loadLangs(array("orders", "sendings", 'companies', 'compta', 'bills', 'projects', 'suppliers', 'products'));
65
66// Get Parameters
67$action = GETPOST('action', 'aZ09');
68$massaction = GETPOST('massaction', 'alpha');
69$show_files = GETPOSTINT('show_files');
70$confirm = GETPOST('confirm', 'alpha');
71$toselect = GETPOST('toselect', 'array:int');
72$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'supplierorderlist';
73$mode = GETPOST('mode', 'alpha');
74
75// Search Criteria
76$search_date_order_startday = GETPOSTINT('search_date_order_startday');
77$search_date_order_startmonth = GETPOSTINT('search_date_order_startmonth');
78$search_date_order_startyear = GETPOSTINT('search_date_order_startyear');
79$search_date_order_endday = GETPOSTINT('search_date_order_endday');
80$search_date_order_endmonth = GETPOSTINT('search_date_order_endmonth');
81$search_date_order_endyear = GETPOSTINT('search_date_order_endyear');
82$search_date_order_start = dol_mktime(0, 0, 0, $search_date_order_startmonth, $search_date_order_startday, $search_date_order_startyear); // Use tzserver
83$search_date_order_end = dol_mktime(23, 59, 59, $search_date_order_endmonth, $search_date_order_endday, $search_date_order_endyear);
84
85$search_date_delivery_startday = GETPOSTINT('search_date_delivery_startday');
86$search_date_delivery_startmonth = GETPOSTINT('search_date_delivery_startmonth');
87$search_date_delivery_startyear = GETPOSTINT('search_date_delivery_startyear');
88$search_date_delivery_endday = GETPOSTINT('search_date_delivery_endday');
89$search_date_delivery_endmonth = GETPOSTINT('search_date_delivery_endmonth');
90$search_date_delivery_endyear = GETPOSTINT('search_date_delivery_endyear');
91$search_date_delivery_start = dol_mktime(0, 0, 0, $search_date_delivery_startmonth, $search_date_delivery_startday, $search_date_delivery_startyear); // Use tzserver
92$search_date_delivery_end = dol_mktime(23, 59, 59, $search_date_delivery_endmonth, $search_date_delivery_endday, $search_date_delivery_endyear);
93
94$search_date_valid_startday = GETPOSTINT('search_date_valid_startday');
95$search_date_valid_startmonth = GETPOSTINT('search_date_valid_startmonth');
96$search_date_valid_startyear = GETPOSTINT('search_date_valid_startyear');
97$search_date_valid_endday = GETPOSTINT('search_date_valid_endday');
98$search_date_valid_endmonth = GETPOSTINT('search_date_valid_endmonth');
99$search_date_valid_endyear = GETPOSTINT('search_date_valid_endyear');
100$search_date_valid_start = dol_mktime(0, 0, 0, $search_date_valid_startmonth, $search_date_valid_startday, $search_date_valid_startyear); // Use tzserver
101$search_date_valid_end = dol_mktime(23, 59, 59, $search_date_valid_endmonth, $search_date_valid_endday, $search_date_valid_endyear);
102
103$search_date_approve_startday = GETPOSTINT('search_date_approve_startday');
104$search_date_approve_startmonth = GETPOSTINT('search_date_approve_startmonth');
105$search_date_approve_startyear = GETPOSTINT('search_date_approve_startyear');
106$search_date_approve_endday = GETPOSTINT('search_date_approve_endday');
107$search_date_approve_endmonth = GETPOSTINT('search_date_approve_endmonth');
108$search_date_approve_endyear = GETPOSTINT('search_date_approve_endyear');
109$search_date_approve_start = dol_mktime(0, 0, 0, $search_date_approve_startmonth, $search_date_approve_startday, $search_date_approve_startyear); // Use tzserver
110$search_date_approve_end = dol_mktime(23, 59, 59, $search_date_approve_endmonth, $search_date_approve_endday, $search_date_approve_endyear);
111
112$search_all = trim(GETPOST('search_all', 'alphanohtml'));
113
114$searchCategorySupplierOrderList = GETPOST('search_category_supplier_order_list', 'array:int');
115$searchCategorySupplierOrderOperator = 0;
116if (GETPOSTISSET('formfilteraction')) {
117 $searchCategorySupplierOrderOperator = GETPOSTINT('search_category_supplier_order_operator');
118} elseif (getDolGlobalString('MAIN_SEARCH_CAT_OR_BY_DEFAULT')) {
119 $searchCategorySupplierOrderOperator = getDolGlobalString('MAIN_SEARCH_CAT_OR_BY_DEFAULT');
120}
121$search_product_category = GETPOSTINT('search_product_category');
122$search_ref = GETPOST('search_ref', 'alpha');
123$search_refsupp = GETPOST('search_refsupp', 'alpha');
124$search_company = GETPOST('search_company', 'alpha');
125$search_company_alias = GETPOST('search_company_alias', 'alpha');
126$search_town = GETPOST('search_town', 'alpha');
127$search_zip = GETPOST('search_zip', 'alpha');
128$search_state = GETPOST("search_state", 'alpha');
129$search_country = GETPOST("search_country", 'aZ09');
130$search_type_thirdparty = GETPOST("search_type_thirdparty", 'intcomma');
131$search_user = GETPOST('search_user', 'intcomma');
132$search_request_author = GETPOST('search_request_author', 'alpha');
133$optioncss = GETPOST('optioncss', 'alpha');
134$socid = GETPOSTINT('socid');
135$search_sale = GETPOST('search_sale', 'intcomma');
136$search_total_ht = GETPOST('search_total_ht', 'alpha');
137$search_total_tva = GETPOST('search_total_tva', 'alpha');
138$search_total_ttc = GETPOST('search_total_ttc', 'alpha');
139$search_multicurrency_code = GETPOST('search_multicurrency_code', 'alpha');
140$search_multicurrency_tx = GETPOST('search_multicurrency_tx', 'alpha');
141$search_note_private = GETPOST('search_note_private', 'alpha');
142$search_note_public = GETPOST('search_note_public', 'alpha');
143$search_multicurrency_montant_ht = GETPOST('search_multicurrency_montant_ht', 'alpha');
144$search_multicurrency_montant_tva = GETPOST('search_multicurrency_montant_tva', 'alpha');
145$search_multicurrency_montant_ttc = GETPOST('search_multicurrency_montant_ttc', 'alpha');
146$optioncss = GETPOST('optioncss', 'alpha');
147$billed = GETPOST('billed', 'int'); // Value '' must be possible
148$search_project_ref = GETPOST('search_project_ref', 'alpha');
149$search_btn = GETPOST('button_search', 'alpha');
150$search_remove_btn = GETPOST('button_removefilter', 'alpha');
151
152if (GETPOSTISARRAY('search_status')) {
153 $search_status = implode(',', GETPOST('search_status', 'array:intcomma'));
154} else {
155 $search_status = (GETPOST('search_status', 'intcomma') != '' ? GETPOST('search_status', 'intcomma') : GETPOST('statut', 'intcomma'));
156}
157
158$search_option = GETPOST('search_option', 'alpha');
159if ($search_option == 'late') {
160 $search_status = '1,2';
161}
162if ($search_option == 'recv_late') {
163 $search_status = '3,4';
164}
165
166
167$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
168$sortfield = GETPOST('sortfield', 'aZ09comma');
169$sortorder = GETPOST('sortorder', 'aZ09comma');
170$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT('page');
171if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
172 // If $page is not defined, or '' or -1 or if we click on clear filters
173 $page = 0;
174}
175$offset = $limit * $page;
176$pageprev = $page - 1;
177$pagenext = $page + 1;
178if (!$sortfield) {
179 $sortfield = 'cf.ref';
180}
181if (!$sortorder) {
182 $sortorder = 'DESC';
183}
184
185// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
187$hookmanager->initHooks(array('supplierorderlist'));
188
189// fetch optionals attributes and labels
190$extrafields->fetch_name_optionals_label($object->table_element);
191$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
192
193$diroutputmassaction = getMultidirTemp($object).'/massgeneration/'.$user->id;
194
195// List of fields to search into when doing a "search in all"
196$fieldstosearchall = array();
197foreach ($object->fields as $key => $val) {
198 if (!empty($val['searchall'])) {
199 $fieldstosearchall['cf.'.$key] = $val['label'];
200 }
201}
202$fieldstosearchall['pd.description'] = 'Description';
203$fieldstosearchall['s.nom'] = "ThirdParty";
204$fieldstosearchall['s.name_alias'] = "AliasNameShort";
205$fieldstosearchall['s.zip'] = "Zip";
206$fieldstosearchall['s.town'] = "Town";
207if (empty($user->socid)) {
208 $fieldstosearchall["cf.note_private"] = "NotePrivate";
209}
210
211$enabledtypetiers = 0;
212
213// Definition of array of fields for columns
214$arrayfields = array(
215 'u.login' => array('label' => "AuthorRequest", 'enabled' => '1', 'position' => 41),
216 's.name_alias' => array('label' => "AliasNameShort", 'position' => 51, 'checked' => '0'),
217 's.town' => array('label' => "Town", 'enabled' => '1', 'position' => 55, 'checked' => '0'),
218 's.zip' => array('label' => "Zip", 'enabled' => '1', 'position' => 56, 'checked' => '1'),
219 'state.nom' => array('label' => "StateShort", 'enabled' => '1', 'position' => 57),
220 'country.code_iso' => array('label' => "Country", 'enabled' => '1', 'position' => 58),
221 'typent.code' => array('label' => "ThirdPartyType", 'enabled' => $enabledtypetiers, 'position' => 59),
222 'cf.total_localtax1' => array('label' => $langs->transcountry("AmountLT1", $mysoc->country_code), 'checked' => '0', 'enabled' => (string) (int) ($mysoc->localtax1_assuj == "1"), 'position' => 140),
223 'cf.total_localtax2' => array('label' => $langs->transcountry("AmountLT2", $mysoc->country_code), 'checked' => '0', 'enabled' => (string) (int) ($mysoc->localtax2_assuj == "1"), 'position' => 145),
224 'cf.note_public' => array('label' => 'NotePublic', 'checked' => '0', 'enabled' => (string) (int) (!getDolGlobalInt('MAIN_LIST_HIDE_PUBLIC_NOTES')), 'position' => 750),
225 'cf.note_private' => array('label' => 'NotePrivate', 'checked' => '0', 'enabled' => (string) (int) (!getDolGlobalInt('MAIN_LIST_HIDE_PRIVATE_NOTES')), 'position' => 760),
226);
227foreach ($object->fields as $key => $val) {
228 // If $val['visible']==0, then we never show the field
229 if (!empty($val['visible'])) {
230 $visible = (int) dol_eval((string) $val['visible'], 1);
231 $arrayfields['cf.'.$key] = array(
232 'label' => $val['label'],
233 'checked' => (($visible < 0) ? '0' : '1'),
234 'enabled' => (string) (int) (abs($visible) != 3 && (bool) dol_eval((string) $val['enabled'], 1)),
235 'position' => $val['position'],
236 'help' => isset($val['help']) ? $val['help'] : ''
237 );
238 }
239}
240// Extra fields
241include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
242
243$object->fields = dol_sort_array($object->fields, 'position');
244$arrayfields = dol_sort_array($arrayfields, 'position');
245
246$error = 0;
247
248// Check only if it's an internal user
249if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) {
250 $search_sale = $user->isExternalUser();
251}
252
253// Security check
254$orderid = GETPOSTINT('orderid');
255if ($user->isExternalUser()) {
256 $socid = $user->isExternalUser();
257}
258$result = restrictedArea($user, 'fournisseur', $orderid, '', 'commande');
259
260$permissiontoread = ($user->hasRight("fournisseur", "commande", "lire") || $user->hasRight("supplier_order", "lire"));
261$permissiontoadd = ($user->hasRight("fournisseur", "commande", "creer") || $user->hasRight("supplier_order", "creer"));
262$permissiontodelete = ($user->hasRight("fournisseur", "commande", "supprimer") || $user->hasRight("supplier_order", "supprimer"));
263$permissiontovalidate = $permissiontoadd;
264$permissiontoapprove = ($user->hasRight("fournisseur", "commande", "approuver") || $user->hasRight("supplier_order", "approuver"));
265
266
267/*
268 * Actions
269 */
270
271if (GETPOST('cancel', 'alpha')) {
272 $action = 'list';
273 $massaction = '';
274}
275if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createsupplierbills') {
276 $massaction = '';
277}
278
279$parameters = array('socid' => $socid, 'arrayfields' => &$arrayfields);
280$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
281if ($reshook < 0) {
282 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
283}
284
285if (empty($reshook)) {
286 // Selection of new fields
287 include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
288
289 // Purge search criteria
290 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
291 $search_categ = '';
292 $search_user = '';
293 $search_sale = '';
294 $search_product_category = '';
295 $searchCategorySupplierOrderList = array();
296 $search_ref = '';
297 $search_refsupp = '';
298 $search_company = '';
299 $search_company_alias = '';
300 $search_town = '';
301 $search_zip = "";
302 $search_state = "";
303 $search_type = '';
304 $search_country = '';
305 $search_type_thirdparty = '';
306 $search_request_author = '';
307 $search_total_ht = '';
308 $search_total_tva = '';
309 $search_total_ttc = '';
310 $search_multicurrency_code = '';
311 $search_multicurrency_tx = '';
312 $search_multicurrency_montant_ht = '';
313 $search_multicurrency_montant_tva = '';
314 $search_multicurrency_montant_ttc = '';
315 $search_project_ref = '';
316 $search_status = '';
317 $search_option = '';
318 $search_date_order_startday = '';
319 $search_date_order_startmonth = '';
320 $search_date_order_startyear = '';
321 $search_date_order_endday = '';
322 $search_date_order_endmonth = '';
323 $search_date_order_endyear = '';
324 $search_date_order_start = '';
325 $search_date_order_end = '';
326 $search_date_delivery_startday = '';
327 $search_date_delivery_startmonth = '';
328 $search_date_delivery_startyear = '';
329 $search_date_delivery_endday = '';
330 $search_date_delivery_endmonth = '';
331 $search_date_delivery_endyear = '';
332 $search_date_delivery_start = '';
333 $search_date_delivery_end = '';
334 $search_date_valid_startday = '';
335 $search_date_valid_startmonth = '';
336 $search_date_valid_startyear = '';
337 $search_date_valid_endday = '';
338 $search_date_valid_endmonth = '';
339 $search_date_valid_endyear = '';
340 $search_date_valid_start = '';
341 $search_date_valid_end = '';
342 $search_date_approve_startday = '';
343 $search_date_approve_startmonth = '';
344 $search_date_approve_startyear = '';
345 $search_date_approve_endday = '';
346 $search_date_approve_endmonth = '';
347 $search_date_approve_endyear = '';
348 $search_date_approve_start = '';
349 $search_date_approve_end = '';
350 $billed = '';
351 $toselect = array();
352 $search_array_options = array();
353 }
354 if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')
355 || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) {
356 $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation
357 }
358
359 // Mass actions
360 $objectclass = 'CommandeFournisseur';
361 $objectlabel = 'SupplierOrders';
362 $uploaddir = getMultidirOutput($object);
363 include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
364
365 if ($action == 'validate' && $permissiontovalidate) {
366 if (GETPOST('confirm') == 'yes') {
367 $objecttmp = new CommandeFournisseur($db);
368 $db->begin();
369 $error = 0;
370
371 foreach ($toselect as $checked) {
372 if ($objecttmp->fetch($checked)) {
373 if ($objecttmp->statut == 0) {
374 $objecttmp->date_commande = dol_now();
375 $result = $objecttmp->valid($user);
376 if ($result >= 0) {
377 // If we have permission, and if we don't need to provide the idwarehouse, we go directly on approved step
378 if (!getDolGlobalString('SUPPLIER_ORDER_NO_DIRECT_APPROVE') && $permissiontoapprove && !(getDolGlobalString('STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER') && $objecttmp->hasProductsOrServices(1))) {
379 $result = $objecttmp->approve($user);
380 setEventMessages($langs->trans("SupplierOrderValidatedAndApproved"), array($objecttmp->ref));
381 } else {
382 setEventMessages($langs->trans("SupplierOrderValidated"), array($objecttmp->ref));
383 }
384 } else {
385 setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
386 $error++;
387 }
388 }
389 }
390 }
391
392 if (!$error) {
393 $db->commit();
394 } else {
395 $db->rollback();
396 }
397 }
398 }
399
400 // Mass action to generate vendor bills
401 if ($massaction == 'confirm_createsupplierbills') {
402 $orders = GETPOST('toselect', 'array:int');
403 $createbills_onebythird = GETPOSTINT('createbills_onebythird');
404 $validate_invoices = GETPOSTINT('validate_invoices');
405
406 $TFact = array();
408 $TFactThird = array();
409
410 $nb_bills_created = 0;
411 $lastid = 0;
412 $lastref = '';
413
414 $db->begin();
415
416 $default_ref_supplier = dol_print_date(dol_now(), '%Y%m%d%H%M%S');
417 $currentIndex = 0;
418 foreach ($orders as $id_order) {
419 $cmd = new CommandeFournisseur($db);
420 if ($cmd->fetch($id_order) <= 0) {
421 continue;
422 }
423
424 $objecttmp = new FactureFournisseur($db);
425 if (!empty($createbills_onebythird) && !empty($TFactThird[$cmd->socid])) {
426 $currentIndex++;
427 $objecttmp = $TFactThird[$cmd->socid]; // If option "one bill per third" is set, we use already created supplier invoice.
428 } else {
429 // Search if the VAT reverse-charge is activated by default in supplier card to resume the information
430 if (!empty($cmd->socid) > 0) {
431 $societe = new Societe($db);
432 $societe->fetch($cmd->socid);
433 $objecttmp->vat_reverse_charge = $societe->vat_reverse_charge;
434 $objecttmp->thirdparty = $societe;
435 }
436 $objecttmp->socid = $cmd->socid;
437 $objecttmp->type = $objecttmp::TYPE_STANDARD;
438 $objecttmp->cond_reglement_id = $cmd->cond_reglement_id;
439 $objecttmp->mode_reglement_id = $cmd->mode_reglement_id;
440 $objecttmp->fk_project = $cmd->fk_project;
441 $objecttmp->multicurrency_code = $cmd->multicurrency_code;
442 $objecttmp->ref_supplier = !empty($cmd->ref_supplier) ? $cmd->ref_supplier : $default_ref_supplier;
443 $default_ref_supplier += 1;
444
445 $datefacture = dol_mktime(12, 0, 0, GETPOSTINT('remonth'), GETPOSTINT('reday'), GETPOSTINT('reyear'));
446 if (empty($datefacture)) {
447 $datefacture = dol_now();
448 }
449
450 $objecttmp->date = $datefacture;
451 $objecttmp->origin = 'order_supplier';
452 $objecttmp->origin_id = (int) $id_order;
453
454 $res = $objecttmp->create($user);
455
456 if ($res > 0) {
457 $nb_bills_created++;
458 $lastref = $objecttmp->ref;
459 $lastid = $objecttmp->id;
460 } else {
461 setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
462 $error++;
463 }
464 }
465
466 if ($objecttmp->id > 0) {
467 if (empty($objecttmp->note_public)) {
468 $objecttmp->note_public = $langs->transnoentities("Orders");
469 }
470
471 $sql = "INSERT INTO ".MAIN_DB_PREFIX."element_element (";
472 $sql .= "fk_source";
473 $sql .= ", sourcetype";
474 $sql .= ", fk_target";
475 $sql .= ", targettype";
476 $sql .= ") VALUES (";
477 $sql .= $id_order;
478 $sql .= ", '".$db->escape($objecttmp->origin)."'";
479 $sql .= ", ".((int) $objecttmp->id);
480 $sql .= ", '".$db->escape($objecttmp->element)."'";
481 $sql .= ")";
482
483 if (!$db->query($sql)) {
484 $error++;
485 }
486
487 if (!$error) {
488 $lines = $cmd->lines;
489 if (empty($lines) && method_exists($cmd, 'fetch_lines')) {
490 $cmd->fetch_lines();
491 $lines = $cmd->lines;
492 }
493
494 $fk_parent_line = 0;
495 $num = count($lines);
496
497 for ($i = 0; $i < $num; $i++) {
498 $desc = ($lines[$i]->desc ? $lines[$i]->desc : $lines[$i]->libelle);
499 // If we build one invoice for several supplier orders, append the source order reference on the invoice line.
500 if (!empty($createbills_onebythird)) {
501 $desc = dol_concatdesc($desc, $langs->trans("SupplierOrder").' '.$cmd->ref.' - '.dol_print_date($cmd->date, 'day'));
502 }
503 if ($lines[$i]->subprice < 0) {
504 require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php';
505
506 // Negative line, we create a discount line
507 $discount = new DiscountAbsolute($db);
508 $discount->fk_soc = $objecttmp->socid;
509 $discount->socid = $objecttmp->socid;
510 $discount->amount_ht = abs($lines[$i]->total_ht);
511 $discount->amount_tva = abs($lines[$i]->total_tva);
512 $discount->amount_ttc = abs($lines[$i]->total_ttc);
513 $discount->tva_tx = $lines[$i]->tva_tx;
514 $discount->fk_user = $user->id;
515 $discount->description = $desc;
516 $discountid = $discount->create($user);
517 if ($discountid > 0) {
518 $result = $objecttmp->insert_discount($discountid);
519 //$result=$discount->link_to_invoice($lineid,$id);
520 } else {
521 setEventMessages($discount->error, $discount->errors, 'errors');
522 $error++;
523 break;
524 }
525 } else {
526 // Positive line
527 $product_type = ($lines[$i]->product_type ? $lines[$i]->product_type : 0);
528 // Date start
529 $date_start = 0;
530 if ($lines[$i]->date_debut_prevue) {
531 $date_start = $lines[$i]->date_debut_prevue;
532 }
533 if ($lines[$i]->date_debut_reel) {
534 $date_start = $lines[$i]->date_debut_reel;
535 }
536 if ($lines[$i]->date_start) {
537 $date_start = $lines[$i]->date_start;
538 }
539 //Date end
540 $date_end = 0;
541 if ($lines[$i]->date_fin_prevue) {
542 $date_end = $lines[$i]->date_fin_prevue;
543 }
544 if ($lines[$i]->date_fin_reel) {
545 $date_end = $lines[$i]->date_fin_reel;
546 }
547 if ($lines[$i]->date_end) {
548 $date_end = $lines[$i]->date_end;
549 }
550 // Reset fk_parent_line for no child products and special product
551 if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9) {
552 $fk_parent_line = 0;
553 }
554
555 $tva_tx = $lines[$i]->tva_tx;
556 // @phan-suppress-next-line PhanTypeMismatchArgumentInternal
557 if (!empty($lines[$i]->vat_src_code) && !preg_match('/\‍(/', (string) $tva_tx)) {
558 $tva_tx .= ' ('.$lines[$i]->vat_src_code.')';
559 }
560
561 $result = $objecttmp->addline(
562 $desc,
563 $lines[$i]->subprice,
564 $tva_tx,
565 $lines[$i]->localtax1_tx,
566 $lines[$i]->localtax2_tx,
567 $lines[$i]->qty,
568 $lines[$i]->fk_product,
569 $lines[$i]->remise_percent,
570 (int) $date_start,
571 (int) $date_end,
572 0,
573 $lines[$i]->info_bits,
574 'HT',
575 $product_type,
576 // we don't use the rank from orderline because we may have lines from several orders
577 -1,
578 0,
579 $lines[$i]->array_options,
580 $lines[$i]->fk_unit,
581 // we use the id of each order, not the id of the first one stored in $objecttmp->origin_id
582 $lines[$i]->fk_commande,
583 $lines[$i]->pa_ht,
584 $lines[$i]->ref_supplier,
585 $lines[$i]->special_code,
586 $fk_parent_line
587 );
588 if ($result > 0) {
589 $lineid = $result;
590 } else {
591 $lineid = 0;
592 $error++;
593 break;
594 }
595 // Defined the new fk_parent_line
596 if ($result > 0 && $lines[$i]->product_type == 9) {
597 $fk_parent_line = $result;
598 }
599 }
600 }
601 }
602 }
603
604 if ($currentIndex <= (getDolGlobalInt("MAXREFONDOC") ? getDolGlobalInt("MAXREFONDOC") : 10)) {
605 $objecttmp->note_public = dol_concatdesc($objecttmp->note_public, $langs->transnoentities($cmd->ref).(empty($cmd->ref_supplier) ? '' : ' ('.$cmd->ref_supplier.')'));
606 $objecttmp->update($user);
607 }
608
609 $cmd->classifyBilled($user); // TODO Move this in workflow like done for sales orders
610
611 if (!empty($createbills_onebythird) && empty($TFactThird[$cmd->socid])) {
612 $TFactThird[$cmd->socid] = $objecttmp;
613 } else {
614 $TFact[$objecttmp->id] = $objecttmp;
615 }
616 }
617
618 // Build doc with all invoices
619 $TAllFact = empty($createbills_onebythird) ? $TFact : $TFactThird;
620 $toselect = array();
621
622 if (!$error && $validate_invoices) {
623 $massaction = $action = 'builddoc';
624
625 foreach ($TAllFact as &$objecttmp) {
626 $objecttmp->validate($user);
627 if ($result <= 0) {
628 $error++;
629 setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
630 break;
631 }
632
633 $id = $objecttmp->id; // For builddoc action
634
635 // Fac builddoc
636 $donotredirect = 1;
637 $upload_dir = getMultidirOutput($objecttmp);
638 $permissiontoadd = ($user->hasRight("fournisseur", "facture", "creer") || $user->hasRight("supplier_invoice", "creer"));
639 //include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
640 }
641
642 $massaction = $action = 'confirm_createsupplierbills';
643 }
644
645 if (!$error) {
646 $db->commit();
647
648 if ($nb_bills_created == 1) {
649 $texttoshow = $langs->trans('BillXCreated', '{s1}');
650 $texttoshow = str_replace('{s1}', '<a href="'.DOL_URL_ROOT.'/fourn/facture/card.php?id='.urlencode((string) ($lastid)).'">'.$lastref.'</a>', $texttoshow);
651 setEventMessages($texttoshow, null, 'mesgs');
652 } else {
653 setEventMessages($langs->trans('BillCreated', $nb_bills_created), null, 'mesgs');
654 }
655
656 // Make a redirect to avoid to bill twice if we make a refresh or back
657 $param = '';
658 if (!empty($mode)) {
659 $param .= '&mode='.urlencode($mode);
660 }
661 if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
662 $param .= '&contextpage='.urlencode($contextpage);
663 }
664 if ($limit > 0 && $limit != $conf->liste_limit) {
665 $param .= '&limit='.((int) $limit);
666 }
667 if ($search_all) {
668 $param .= '&search_all='.urlencode($search_all);
669 }
670 if ($socid > 0) {
671 $param .= '&socid='.urlencode((string) ($socid));
672 }
673 if ($search_status != '') {
674 $param .= '&search_status='.urlencode($search_status);
675 }
676 if ($search_option) {
677 $param .= '&search_option='.urlencode($search_option);
678 }
679 if ($search_date_order_startday) {
680 $param .= '&search_date_order_startday='.urlencode((string) ($search_date_order_startday));
681 }
682 if ($search_date_order_startmonth) {
683 $param .= '&search_date_order_startmonth='.urlencode((string) ($search_date_order_startmonth));
684 }
685 if ($search_date_order_startyear) {
686 $param .= '&search_date_order_startyear='.urlencode((string) ($search_date_order_startyear));
687 }
688 if ($search_date_order_endday) {
689 $param .= '&search_date_order_endday='.urlencode((string) ($search_date_order_endday));
690 }
691 if ($search_date_order_endmonth) {
692 $param .= '&search_date_order_endmonth='.urlencode((string) ($search_date_order_endmonth));
693 }
694 if ($search_date_order_endyear) {
695 $param .= '&search_date_order_endyear='.urlencode((string) ($search_date_order_endyear));
696 }
697 if ($search_date_delivery_startday) {
698 $param .= '&search_date_delivery_startday='.urlencode((string) ($search_date_delivery_startday));
699 }
700 if ($search_date_delivery_startmonth) {
701 $param .= '&search_date_delivery_startmonth='.urlencode((string) ($search_date_delivery_startmonth));
702 }
703 if ($search_date_delivery_startyear) {
704 $param .= '&search_date_delivery_startyear='.urlencode((string) ($search_date_delivery_startyear));
705 }
706 if ($search_date_delivery_endday) {
707 $param .= '&search_date_delivery_endday='.urlencode((string) ($search_date_delivery_endday));
708 }
709 if ($search_date_delivery_endmonth) {
710 $param .= '&search_date_delivery_endmonth='.urlencode((string) ($search_date_delivery_endmonth));
711 }
712 if ($search_date_delivery_endyear) {
713 $param .= '&search_date_delivery_endyear='.urlencode((string) ($search_date_delivery_endyear));
714 }
715 if ($search_date_valid_startday) {
716 $param .= '&search_date_valid_startday='.urlencode((string) ($search_date_valid_startday));
717 }
718 if ($search_date_valid_startmonth) {
719 $param .= '&search_date_valid_startmonth='.urlencode((string) ($search_date_valid_startmonth));
720 }
721 if ($search_date_valid_startyear) {
722 $param .= '&search_date_valid_startyear='.urlencode((string) ($search_date_valid_startyear));
723 }
724 if ($search_date_valid_endday) {
725 $param .= '&search_date_valid_endday='.urlencode((string) ($search_date_valid_endday));
726 }
727 if ($search_date_valid_endmonth) {
728 $param .= '&search_date_valid_endmonth='.urlencode((string) ($search_date_valid_endmonth));
729 }
730 if ($search_date_valid_endyear) {
731 $param .= '&search_date_valid_endyear='.urlencode((string) ($search_date_valid_endyear));
732 }
733 if ($search_date_approve_startday) {
734 $param .= '&search_date_approve_startday='.urlencode((string) ($search_date_approve_startday));
735 }
736 if ($search_date_approve_startmonth) {
737 $param .= '&search_date_approve_startmonth='.urlencode((string) ($search_date_approve_startmonth));
738 }
739 if ($search_date_approve_startyear) {
740 $param .= '&search_date_approve_startyear='.urlencode((string) ($search_date_approve_startyear));
741 }
742 if ($search_date_approve_endday) {
743 $param .= '&search_date_approve_endday='.urlencode((string) ($search_date_approve_endday));
744 }
745 if ($search_date_approve_endmonth) {
746 $param .= '&search_date_approve_endmonth='.urlencode((string) ($search_date_approve_endmonth));
747 }
748 if ($search_date_approve_endyear) {
749 $param .= '&search_date_approve_endyear='.urlencode((string) ($search_date_approve_endyear));
750 }
751 if ($search_ref) {
752 $param .= '&search_ref='.urlencode($search_ref);
753 }
754 if ($search_company) {
755 $param .= '&search_company='.urlencode($search_company);
756 }
757 if ($search_company_alias) {
758 $param .= '&search_company_alias='.urlencode($search_company_alias);
759 }
760 //if ($search_ref_customer) $param .= '&search_ref_customer='.urlencode($search_ref_customer);
761 if ($search_user > 0) {
762 $param .= '&search_user='.urlencode((string) ($search_user));
763 }
764 if ($searchCategorySupplierOrderOperator == 1) {
765 $param .= "&search_category_supplier_order_operator=".urlencode((string) ($searchCategorySupplierOrderOperator));
766 }
767 foreach ($searchCategorySupplierOrderList as $searchCategorySupplierOrder) {
768 $param .= "&search_category_order_list[]=".urlencode($searchCategorySupplierOrder);
769 }
770 if ($search_sale > 0) {
771 $param .= '&search_sale='.urlencode($search_sale);
772 }
773 if ($search_total_ht != '') {
774 $param .= '&search_total_ht='.urlencode($search_total_ht);
775 }
776 if ($search_total_tva != '') {
777 $param .= '&search_total_tva='.urlencode($search_total_tva);
778 }
779 if ($search_total_ttc != '') {
780 $param .= '&search_total_ttc='.urlencode($search_total_ttc);
781 }
782 if ($search_project_ref >= 0) {
783 $param .= "&search_project_ref=".urlencode($search_project_ref);
784 }
785 if ($show_files) {
786 $param .= '&show_files='.urlencode((string) ($show_files));
787 }
788 if ($optioncss != '') {
789 $param .= '&optioncss='.urlencode($optioncss);
790 }
791 if ($billed != '') {
792 $param .= '&billed='.((int) ($billed));
793 }
794
795 header("Location: ".$_SERVER['PHP_SELF'].'?'.$param);
796 exit;
797 } else {
798 $db->rollback();
799 $action = 'create';
800 $_GET["origin"] = GETPOST("origin", 'alpha');
801 $_GET["originid"] = GETPOSTINT("originid");
802 setEventMessages("Error", null, 'errors');
803 $error++;
804 }
805 }
806}
807
808
809/*
810 * View
811 */
812
813$now = dol_now();
814
815$form = new Form($db);
816$thirdpartytmp = new Fournisseur($db);
817$commandestatic = new CommandeFournisseur($db);
818$formfile = new FormFile($db);
819$formorder = new FormOrder($db);
820$formother = new FormOther($db);
821$formcompany = new FormCompany($db);
822
823$title = $langs->trans("SuppliersOrders");
824if ($socid > 0) {
825 $fourn = new Fournisseur($db);
826 $fourn->fetch($socid);
827 $title .= ' - '.$fourn->name;
828}
829
830if ($billed > 0) {
831 $title .= ' - '.$langs->trans("Billed");
832}
833
834//$help_url="EN:Module_Customers_Orders|FR:Module_Commandes_Clients|ES:Módulo_Pedidos_de_clientes";
835$help_url = '';
836
837$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
838$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
839
840$sql = 'SELECT';
841if ($search_all) {
842 $sql = 'SELECT DISTINCT';
843}
844$sql .= ' s.rowid as socid, s.nom as name, s.name_alias as alias, s.town, s.zip, s.fk_pays, s.client, s.fournisseur, s.code_client, s.email,';
845$sql .= " typent.code as typent_code,";
846$sql .= " state.code_departement as state_code, state.nom as state_name,";
847$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 delivery_date, cf.date_valid, cf.date_approve,";
848$sql .= ' cf.localtax1 as total_localtax1, cf.localtax2 as total_localtax2,';
849$sql .= ' cf.fk_multicurrency, cf.multicurrency_code, cf.multicurrency_tx, cf.multicurrency_total_ht, cf.multicurrency_total_tva, cf.multicurrency_total_ttc,';
850$sql .= ' cf.date_creation as date_creation, cf.tms as date_modification,';
851$sql .= ' cf.note_public, cf.note_private,';
852$sql .= " p.rowid as project_id, p.ref as project_ref, p.title as project_title,";
853$sql .= " u.firstname, u.lastname, u.photo, u.login, u.email as user_email, u.statut as user_status";
854// Add fields from extrafields
855if (!empty($extrafields->attributes[$object->table_element]['label'])) {
856 foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
857 $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : '');
858 }
859}
860// Add fields from hooks
861$parameters = array();
862$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook
863$sql .= $hookmanager->resPrint;
864
865$sqlfields = $sql; // $sql fields to remove for count total
866
867$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
868$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays)";
869$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typent)";
870$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)";
871$sql .= ", ".MAIN_DB_PREFIX."commande_fournisseur as cf";
872if (!empty($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
873 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (cf.rowid = ef.fk_object)";
874}
875if ($search_all) {
876 $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'commande_fournisseurdet as pd ON cf.rowid=pd.fk_commande';
877}
878$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON cf.fk_user_author = u.rowid";
879$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = cf.fk_projet";
880$parameters = array();
881$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object); // Note that $action and $object may have been modified by hook
882$sql .= $hookmanager->resPrint;
883$sql .= ' WHERE cf.fk_soc = s.rowid';
884$sql .= ' AND cf.entity IN ('.getEntity('supplier_order').')';
885if ($socid > 0) {
886 $sql .= " AND s.rowid = ".((int) $socid);
887}
888if ($search_ref) {
889 $sql .= natural_search('cf.ref', $search_ref);
890}
891if ($search_refsupp) {
892 $sql .= natural_search("cf.ref_supplier", $search_refsupp);
893}
894if ($search_all) {
895 $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
896}
897if (empty($arrayfields['s.name_alias']['checked']) && $search_company) {
898 $sql .= natural_search(array("s.nom", "s.name_alias"), $search_company);
899} else {
900 if ($search_company) {
901 $sql .= natural_search('s.nom', $search_company);
902 }
903 if ($search_company_alias) {
904 $sql .= natural_search('s.name_alias', $search_company_alias);
905 }
906}
907if ($search_request_author) {
908 $sql .= natural_search(array('u.lastname', 'u.firstname', 'u.login'), $search_request_author);
909}
910if ($billed != '' && $billed != '-1') {
911 $sql .= " AND cf.billed = ".((int) $billed);
912}
913//Required triple check because statut=0 means draft filter
914if (GETPOST('statut', 'intcomma') !== '') {
915 $sql .= " AND cf.fk_statut IN (".$db->sanitize($db->escape($db->escape(GETPOST('statut', 'intcomma')))).")";
916}
917if ($search_status != '' && $search_status != '-1') {
918 $sql .= " AND cf.fk_statut IN (".$db->sanitize($db->escape($search_status)).")";
919}
920if ($search_option == 'late') {
921 $sql .= " AND cf.date_commande < '".$db->idate(dol_now() - $conf->order->fournisseur->warning_delay)."'";
922}
923if ($search_date_order_start) {
924 $sql .= " AND cf.date_commande >= '".$db->idate($search_date_order_start)."'";
925}
926if ($search_date_order_end) {
927 $sql .= " AND cf.date_commande <= '".$db->idate($search_date_order_end)."'";
928}
929if ($search_date_delivery_start) {
930 $sql .= " AND cf.date_livraison >= '".$db->idate($search_date_delivery_start)."'";
931}
932if ($search_date_delivery_end) {
933 $sql .= " AND cf.date_livraison <= '".$db->idate($search_date_delivery_end)."'";
934}
935if ($search_date_valid_start) {
936 $sql .= " AND cf.date_valid >= '".$db->idate($search_date_valid_start)."'";
937}
938if ($search_note_public) {
939 $sql .= " AND cf.note_public LIKE '%".$db->escape($db->escapeforlike($search_note_public))."%'";
940}
941if ($search_date_approve_start) {
942 $sql .= " AND cf.date_livraison >= '".$db->idate($search_date_approve_start)."'";
943}
944if ($search_date_valid_end) {
945 $sql .= " AND cf.date_valid <= '".$db->idate($search_date_valid_end)."'";
946}
947if ($search_date_approve_start) {
948 $sql .= " AND cf.date_livraison >= '".$db->idate($search_date_approve_start)."'";
949}
950if ($search_date_approve_end) {
951 $sql .= " AND cf.date_livraison <= '".$db->idate($search_date_approve_end)."'";
952}
953if ($search_town) {
954 $sql .= natural_search('s.town', $search_town);
955}
956if ($search_zip) {
957 $sql .= natural_search("s.zip", $search_zip);
958}
959if ($search_state) {
960 $sql .= natural_search("state.nom", $search_state);
961}
962if ($search_country) {
963 $sql .= " AND s.fk_pays IN (".$db->sanitize($db->escape($search_country)).')';
964}
965if ($search_type_thirdparty != '' && $search_type_thirdparty > 0) {
966 $sql .= " AND s.fk_typent IN (".$db->sanitize($db->escape($search_type_thirdparty)).')';
967}
968/*if ($search_sale > 0) {
969 $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $search_sale);
970}*/
971if ($search_user > 0) {
972 $sql .= " AND EXISTS (";
973 $sql .= " SELECT ec.rowid ";
974 $sql .= " FROM " . MAIN_DB_PREFIX . "element_contact as ec";
975 $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "c_type_contact as tc ON tc.rowid = ec.fk_c_type_contact";
976 $sql .= " WHERE ec.element_id = cf.rowid AND ec.fk_socpeople = " . ((int) $search_user);
977 $sql .= " AND tc.element = 'order_supplier' AND tc.source = 'internal'";
978 $sql .= ")";
979}
980if ($search_total_ht != '') {
981 $sql .= natural_search('cf.total_ht', $search_total_ht, 1);
982}
983if ($search_total_tva != '') {
984 $sql .= natural_search('cf.total_tva', $search_total_tva, 1);
985}
986if ($search_total_ttc != '') {
987 $sql .= natural_search('cf.total_ttc', $search_total_ttc, 1);
988}
989if ($search_multicurrency_code != '') {
990 $sql .= " AND cf.multicurrency_code = '".$db->escape($search_multicurrency_code)."'";
991}
992if ($search_multicurrency_tx != '') {
993 $sql .= natural_search('cf.multicurrency_tx', $search_multicurrency_tx, 1);
994}
995if ($search_multicurrency_montant_ht != '') {
996 $sql .= natural_search('cf.multicurrency_total_ht', $search_multicurrency_montant_ht, 1);
997}
998if ($search_multicurrency_montant_tva != '') {
999 $sql .= natural_search('cf.multicurrency_total_tva', $search_multicurrency_montant_tva, 1);
1000}
1001if ($search_multicurrency_montant_ttc != '') {
1002 $sql .= natural_search('cf.multicurrency_total_ttc', $search_multicurrency_montant_ttc, 1);
1003}
1004if ($search_project_ref != '') {
1005 $sql .= natural_search("p.ref", $search_project_ref);
1006}
1007// Search on sale representative
1008if ($search_sale && $search_sale != '-1') {
1009 if ($search_sale == -2) {
1010 $sql .= " AND NOT EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc WHERE sc.fk_soc = cf.fk_soc)";
1011 } elseif ($search_sale > 0) {
1012 $sql .= " AND EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc WHERE sc.fk_soc = cf.fk_soc AND sc.fk_user = ".((int) $search_sale).")";
1013 }
1014}
1015// Search for tag/category ($searchCategorySupplierOrderList is an array of ID)
1016if (!empty($searchCategorySupplierOrderList)) {
1017 $searchCategorySupplierOrderSqlList = array();
1018 $listofcategoryid = '';
1019 foreach ($searchCategorySupplierOrderList as $searchCategorySupplierOrder) {
1020 if (intval($searchCategorySupplierOrder) == -2) {
1021 $searchCategorySupplierOrderSqlList[] = "NOT EXISTS (SELECT ck.fk_supplier_order FROM ".MAIN_DB_PREFIX."categorie_supplier_order as ck WHERE cf.rowid = ck.fk_supplier_order)";
1022 } elseif (intval($searchCategorySupplierOrder) > 0) {
1023 if ($searchCategorySupplierOrderOperator == 0) {
1024 $searchCategorySupplierOrderSqlList[] = " EXISTS (SELECT ck.fk_supplier_order FROM ".MAIN_DB_PREFIX."categorie_supplier_order as ck WHERE cf.rowid = ck.fk_supplier_order AND ck.fk_categorie = ".((int) $searchCategorySupplierOrder).")";
1025 } else {
1026 $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategorySupplierOrder);
1027 }
1028 }
1029 }
1030 if ($listofcategoryid) {
1031 $searchCategorySupplierOrderSqlList[] = " EXISTS (SELECT ck.fk_supplier_order FROM ".MAIN_DB_PREFIX."categorie_supplier_order as ck WHERE cf.rowid = ck.fk_supplier_order AND ck.fk_categorie IN (".$db->sanitize($listofcategoryid)."))";
1032 }
1033 if ($searchCategorySupplierOrderOperator == 1) {
1034 if (!empty($searchCategorySupplierOrderSqlList)) {
1035 $sql .= " AND (".implode(' OR ', $searchCategorySupplierOrderSqlList).")";
1036 }
1037 } else {
1038 if (!empty($searchCategorySupplierOrderSqlList)) {
1039 $sql .= " AND (".implode(' AND ', $searchCategorySupplierOrderSqlList).")";
1040 }
1041 }
1042}
1043// Search for tag/category ($searchCategoryProductList is an array of ID)
1044$searchCategoryProductOperator = GETPOSTINT('search_category_product_operator');
1045$searchCategoryProductList = array($search_product_category);
1046if (!empty($searchCategoryProductList)) {
1047 $searchCategoryProductSqlList = array();
1048 $listofcategoryid = '';
1049 foreach ($searchCategoryProductList as $searchCategoryProduct) {
1050 if (intval($searchCategoryProduct) == -2) {
1051 $searchCategoryProductSqlList[] = "NOT EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX."categorie_product as ck, ".MAIN_DB_PREFIX."commande_fournisseurdet as cd WHERE cd.fk_commande = cf.rowid AND cd.fk_product = ck.fk_product)";
1052 } elseif (intval($searchCategoryProduct) > 0) {
1053 if ($searchCategoryProductOperator == 0) {
1054 $searchCategoryProductSqlList[] = " EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX."categorie_product as ck, ".MAIN_DB_PREFIX."commande_fournisseurdet as cd WHERE cd.fk_commande = cf.rowid AND cd.fk_product = ck.fk_product AND ck.fk_categorie = ".((int) $searchCategoryProduct).")";
1055 } else {
1056 $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryProduct);
1057 }
1058 }
1059 }
1060 if ($listofcategoryid) {
1061 $searchCategoryProductSqlList[] = " EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX."categorie_product as ck, ".MAIN_DB_PREFIX."commande_fournisseurdet as cd WHERE cd.fk_commande = cf.rowid AND cd.fk_product = ck.fk_product AND ck.fk_categorie IN (".$db->sanitize($listofcategoryid)."))";
1062 }
1063 if ($searchCategoryProductOperator == 1) {
1064 if (!empty($searchCategoryProductSqlList)) {
1065 $sql .= " AND (".implode(' OR ', $searchCategoryProductSqlList).")";
1066 }
1067 } else {
1068 if (!empty($searchCategoryProductSqlList)) {
1069 $sql .= " AND (".implode(' AND ', $searchCategoryProductSqlList).")";
1070 }
1071 }
1072}
1073// Add where from extra fields
1074include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
1075// Add where from hooks
1076$parameters = array();
1077$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook
1078$sql .= $hookmanager->resPrint;
1079
1080// Count total nb of records
1081$nbtotalofrecords = '';
1082if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
1083 /* The fast and low memory method to get and count full list converts the sql into a sql count */
1084 $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql);
1085 $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount);
1086 $resql = $db->query($sqlforcount);
1087 if ($resql) {
1088 $objforcount = $db->fetch_object($resql);
1089 $nbtotalofrecords = $objforcount->nbtotalofrecords;
1090 } else {
1092 }
1093
1094 if (($page * $limit) > (int) $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
1095 $page = 0;
1096 $offset = 0;
1097 }
1098 $db->free($resql);
1099}
1100
1101$sql .= $db->order($sortfield, $sortorder);
1102if ($limit) {
1103 $sql .= $db->plimit($limit + 1, $offset);
1104}
1105//print $sql;
1106
1107$resql = $db->query($sql);
1108if ($resql) {
1109 $num = $db->num_rows($resql);
1110
1111 $arrayofselected = is_array($toselect) ? $toselect : array();
1112
1113 if ($num == 1 && getDolGlobalString('MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all) {
1114 $obj = $db->fetch_object($resql);
1115 $id = $obj->rowid;
1116 header("Location: ".DOL_URL_ROOT.'/fourn/commande/card.php?id='.$id);
1117 exit;
1118 }
1119
1120 llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'bodyforlist mod-supplier-order page-list');
1121
1122 $param = '';
1123 if (!empty($mode)) {
1124 $param .= '&mode='.urlencode($mode);
1125 }
1126 if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
1127 $param .= '&contextpage='.urlencode($contextpage);
1128 }
1129 if ($limit > 0 && $limit != $conf->liste_limit) {
1130 $param .= '&limit='.((int) $limit);
1131 }
1132 if ($search_all) {
1133 $param .= '&search_all='.urlencode($search_all);
1134 }
1135 if ($socid > 0) {
1136 $param .= '&socid='.urlencode((string) ($socid));
1137 }
1138 if ($search_all) {
1139 $param .= "&search_all=".urlencode($search_all);
1140 }
1141 if ($search_date_order_startday) {
1142 $param .= '&search_date_order_startday='.urlencode((string) ($search_date_order_startday));
1143 }
1144 if ($search_date_order_startmonth) {
1145 $param .= '&search_date_order_startmonth='.urlencode((string) ($search_date_order_startmonth));
1146 }
1147 if ($search_date_order_startyear) {
1148 $param .= '&search_date_order_startyear='.urlencode((string) ($search_date_order_startyear));
1149 }
1150 if ($search_date_order_endday) {
1151 $param .= '&search_date_order_endday='.urlencode((string) ($search_date_order_endday));
1152 }
1153 if ($search_date_order_endmonth) {
1154 $param .= '&search_date_order_endmonth='.urlencode((string) ($search_date_order_endmonth));
1155 }
1156 if ($search_date_order_endyear) {
1157 $param .= '&search_date_order_endyear='.urlencode((string) ($search_date_order_endyear));
1158 }
1159 if ($search_date_delivery_startday) {
1160 $param .= '&search_date_delivery_startday='.urlencode((string) ($search_date_delivery_startday));
1161 }
1162 if ($search_date_delivery_startmonth) {
1163 $param .= '&search_date_delivery_startmonth='.urlencode((string) ($search_date_delivery_startmonth));
1164 }
1165 if ($search_date_delivery_startyear) {
1166 $param .= '&search_date_delivery_startyear='.urlencode((string) ($search_date_delivery_startyear));
1167 }
1168 if ($search_date_delivery_endday) {
1169 $param .= '&search_date_delivery_endday='.urlencode((string) ($search_date_delivery_endday));
1170 }
1171 if ($search_date_delivery_endmonth) {
1172 $param .= '&search_date_delivery_endmonth='.urlencode((string) ($search_date_delivery_endmonth));
1173 }
1174 if ($search_date_delivery_endyear) {
1175 $param .= '&search_date_delivery_endyear='.urlencode((string) ($search_date_delivery_endyear));
1176 }
1177 if ($search_date_valid_startday) {
1178 $param .= '&search_date_valid_startday='.urlencode((string) ($search_date_valid_startday));
1179 }
1180 if ($search_date_valid_startmonth) {
1181 $param .= '&search_date_valid_startmonth='.urlencode((string) ($search_date_valid_startmonth));
1182 }
1183 if ($search_date_valid_startyear) {
1184 $param .= '&search_date_valid_startyear='.urlencode((string) ($search_date_valid_startyear));
1185 }
1186 if ($search_date_valid_endday) {
1187 $param .= '&search_date_valid_endday='.urlencode((string) ($search_date_valid_endday));
1188 }
1189 if ($search_date_valid_endmonth) {
1190 $param .= '&search_date_valid_endmonth='.urlencode((string) ($search_date_valid_endmonth));
1191 }
1192 if ($search_date_valid_endyear) {
1193 $param .= '&search_date_valid_endyear='.urlencode((string) ($search_date_valid_endyear));
1194 }
1195 if ($search_date_approve_startday) {
1196 $param .= '&search_date_approve_startday='.urlencode((string) ($search_date_approve_startday));
1197 }
1198 if ($search_date_approve_startmonth) {
1199 $param .= '&search_date_approve_startmonth='.urlencode((string) ($search_date_approve_startmonth));
1200 }
1201 if ($search_date_approve_startyear) {
1202 $param .= '&search_date_approve_startyear='.urlencode((string) ($search_date_approve_startyear));
1203 }
1204 if ($search_date_approve_endday) {
1205 $param .= '&search_date_approve_endday='.urlencode((string) ($search_date_approve_endday));
1206 }
1207 if ($search_date_approve_endmonth) {
1208 $param .= '&search_date_approve_endmonth='.urlencode((string) ($search_date_approve_endmonth));
1209 }
1210 if ($search_date_approve_endyear) {
1211 $param .= '&search_date_approve_endyear='.urlencode((string) ($search_date_approve_endyear));
1212 }
1213 if ($search_ref) {
1214 $param .= '&search_ref='.urlencode($search_ref);
1215 }
1216 if ($search_company) {
1217 $param .= '&search_company='.urlencode($search_company);
1218 }
1219 if ($search_company_alias) {
1220 $param .= '&search_company_alias='.urlencode($search_company_alias);
1221 }
1222 if ($search_user > 0) {
1223 $param .= '&search_user='.urlencode((string) ($search_user));
1224 }
1225 if ($search_request_author) {
1226 $param .= '&search_request_author='.urlencode($search_request_author);
1227 }
1228 if ($search_sale > 0) {
1229 $param .= '&search_sale='.urlencode($search_sale);
1230 }
1231 if ($search_total_ht != '') {
1232 $param .= '&search_total_ht='.urlencode($search_total_ht);
1233 }
1234 if ($search_total_ttc != '') {
1235 $param .= "&search_total_ttc=".urlencode($search_total_ttc);
1236 }
1237 if ($search_multicurrency_code != '') {
1238 $param .= '&search_multicurrency_code='.urlencode($search_multicurrency_code);
1239 }
1240 if ($search_multicurrency_tx != '') {
1241 $param .= '&search_multicurrency_tx='.urlencode($search_multicurrency_tx);
1242 }
1243 if ($search_multicurrency_montant_ht != '') {
1244 $param .= '&search_multicurrency_montant_ht='.urlencode($search_multicurrency_montant_ht);
1245 }
1246 if ($search_multicurrency_montant_tva != '') {
1247 $param .= '&search_multicurrency_montant_tva='.urlencode($search_multicurrency_montant_tva);
1248 }
1249 if ($search_multicurrency_montant_ttc != '') {
1250 $param .= '&search_multicurrency_montant_ttc='.urlencode($search_multicurrency_montant_ttc);
1251 }
1252 if ($search_refsupp) {
1253 $param .= "&search_refsupp=".urlencode($search_refsupp);
1254 }
1255 if ($search_status != '' && $search_status != '-1') {
1256 $param .= "&search_status=".urlencode($search_status);
1257 }
1258 if ($search_option) {
1259 $param .= "&search_option=".urlencode($search_option);
1260 }
1261 if ($search_project_ref >= 0) {
1262 $param .= "&search_project_ref=".urlencode($search_project_ref);
1263 }
1264 if ($billed != '') {
1265 $param .= "&billed=".((int) $billed);
1266 }
1267 if ($show_files) {
1268 $param .= '&show_files='.urlencode((string) ($show_files));
1269 }
1270 if ($optioncss != '') {
1271 $param .= '&optioncss='.urlencode($optioncss);
1272 }
1273 if ($search_type_thirdparty != '' && $search_type_thirdparty > 0) {
1274 $param .= '&search_type_thirdparty='.urlencode((string) ($search_type_thirdparty));
1275 }
1276
1277 // Add $param from extra fields
1278 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
1279
1280 $parameters = array('param' => &$param);
1281 $reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object); // Note that $action and $object may have been modified by hook
1282 $param .= $hookmanager->resPrint;
1283
1284 // List of mass actions available
1285 $arrayofmassactions = array(
1286 'generate_doc' => img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("ReGeneratePDF"),
1287 'builddoc' => img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
1288 'presend' => img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
1289 );
1290 if (isModEnabled('category') && $user->hasRight("fournisseur", "commande", "lire")) {
1291 $arrayofmassactions['preaffecttag'] = img_picto('', 'category', 'class="pictofixedwidth"').$langs->trans("AffectTag");
1292 }
1293 if ($permissiontovalidate) {
1294 if ($permissiontoapprove && !getDolGlobalString('SUPPLIER_ORDER_NO_DIRECT_APPROVE')) {
1295 $arrayofmassactions['prevalidate'] = img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("ValidateAndApprove");
1296 } else {
1297 $arrayofmassactions['prevalidate'] = img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("Validate");
1298 }
1299 }
1300
1301 if ($user->hasRight('fournisseur', 'facture', 'creer') || $user->hasRight("supplier_invoice", "creer")) {
1302 $arrayofmassactions['createbills'] = img_picto('', 'supplier_invoice', 'class="pictofixedwidth"').$langs->trans("CreateInvoiceForThisSupplier");
1303 }
1304 if ($permissiontodelete) {
1305 $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
1306 }
1307 if (in_array($massaction, array('presend', 'predelete', 'createbills'))) {
1308 $arrayofmassactions = array();
1309 }
1310 $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
1311
1312 $url = DOL_URL_ROOT.'/fourn/commande/card.php?action=create';
1313 if ($socid > 0) {
1314 $url .= '&socid='.((int) $socid);
1315 $url .= '&backtopage='.urlencode(DOL_URL_ROOT.'/fourn/commande/list.php?socid='.((int) $socid));
1316 }
1317 $newcardbutton = '';
1318 $newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss' => 'reposition'));
1319 $newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss' => 'reposition'));
1320 $newcardbutton .= dolGetButtonTitle($langs->trans('Statistics'), '', 'fa fa-chart-bar imgforviewmode', DOL_URL_ROOT.'/commande/stats/index.php?mode=supplier'.preg_replace('/(&|\?)*(mode|groupby)=[^&]+/', '', $param), '', ($mode == 'statistics' ? 2 : 1), array('morecss' => 'reposition'));
1321 $newcardbutton .= dolGetButtonTitleSeparator();
1322 $newcardbutton .= dolGetButtonTitle($langs->trans('NewSupplierOrderShort'), '', 'fa fa-plus-circle', $url, '', (int) $permissiontoadd);
1323
1324 // Lines of title fields
1325 print '<form method="POST" id="searchFormList" action="'.dolBuildUrl($_SERVER["PHP_SELF"]).'">';
1326 if ($optioncss != '') {
1327 print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
1328 }
1329 print '<input type="hidden" name="token" value="'.newToken().'">';
1330 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
1331 print '<input type="hidden" name="action" value="list">';
1332 print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
1333 print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
1334 print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
1335 print '<input type="hidden" name="socid" value="'.$socid.'">';
1336 print '<input type="hidden" name="mode" value="'.$mode.'">';
1337
1338 print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'supplier_order', 0, $newcardbutton, '', $limit, 0, 0, 1);
1339
1340 $topicmail = "SendOrderRef";
1341 $modelmail = "order_supplier_send";
1342 $objecttmp = new CommandeFournisseur($db); // in case $object is not the good object
1343 $trackid = 'sord'.$object->id;
1344 include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
1345
1346 if ($massaction == 'prevalidate') {
1347 print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmMassValidation"), $langs->trans("ConfirmMassValidationQuestion"), "validate", null, '', 0, 200, 500, 1);
1348 }
1349
1350 if ($massaction == 'createbills') {
1351 //var_dump($_REQUEST);
1352 print '<input type="hidden" name="massaction" value="confirm_createsupplierbills">';
1353
1354 print '<table class="noborder centpercent">';
1355 print '<tr>';
1356 print '<td class="titlefield">';
1357 print $langs->trans('DateInvoice');
1358 print '</td>';
1359 print '<td>';
1360 print $form->selectDate('', '', 0, 0, 0, '', 1, 1);
1361 print '</td>';
1362 print '</tr>';
1363 print '<tr>';
1364 print '<td>';
1365 print $langs->trans('CreateOneBillByThird');
1366 print '</td>';
1367 print '<td>';
1368 print $form->selectyesno('createbills_onebythird', '', 1);
1369 print '</td>';
1370 print '</tr>';
1371 print '<tr>';
1372 print '<td>';
1373 print $langs->trans('ValidateInvoices');
1374 print '</td>';
1375 print '<td>';
1376 print $form->selectyesno('validate_invoices', 1, 1);
1377 print '</td>';
1378 print '</tr>';
1379 print '</table>';
1380
1381 print '<div class="center">';
1382 print '<input type="submit" class="button" id="createbills" name="createbills" value="'.$langs->trans('CreateInvoiceForThisCustomer').'"> ';
1383 print '<input type="submit" class="button button-cancel" id="cancel" name="cancel" value="'.$langs->trans("Cancel").'">';
1384 print '</div>';
1385 print '<br>';
1386 print '<br>';
1387 }
1388
1389 if ($search_all) {
1390 foreach ($fieldstosearchall as $key => $val) {
1391 $fieldstosearchall[$key] = $langs->trans($val);
1392 }
1393 print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).implode(', ', $fieldstosearchall).'</div>';
1394 }
1395
1396 $moreforfilter = '';
1397 if (isModEnabled('category') && $user->hasRight('categorie', 'read')) {
1398 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcategory.class.php';
1399 $formcategory = new FormCategory($db);
1400 $moreforfilter .= $formcategory->getFilterBox(Categorie::TYPE_SUPPLIER_ORDER, $searchCategorySupplierOrderList, 'minwidth300', $searchCategorySupplierOrderOperator ? $searchCategorySupplierOrderOperator : 0);
1401 }
1402 // If the user can view prospects other than his'
1403 if ($user->hasRight("user", "user", "lire")) {
1404 $langs->load("commercial");
1405 $moreforfilter .= '<div class="divsearchfield">';
1406 $tmptitle = $langs->trans('ThirdPartiesOfSaleRepresentative');
1407 $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, $tmptitle, 'maxwidth250 widthcentpercentminusx');
1408 $moreforfilter .= '</div>';
1409 }
1410 // If the user can view other users
1411 if ($user->hasRight("user", "user", "lire")) {
1412 $moreforfilter .= '<div class="divsearchfield">';
1413 $tmptitle = $langs->trans('LinkedToSpecificUsers');
1414 $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$form->select_dolusers($search_user, 'search_user', $tmptitle, null, 0, '', '', '0', 0, 0, '', 0, '', 'maxwidth250 widthcentpercentminusx');
1415 $moreforfilter .= '</div>';
1416 }
1417 // If the user can view prospects other than his'
1418 if (isModEnabled('category') && $user->hasRight('categorie', 'lire') && ($user->hasRight('produit', 'lire') || $user->hasRight('service', 'lire'))) {
1419 include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
1420 $moreforfilter .= '<div class="divsearchfield">';
1421 $tmptitle = $langs->trans('IncludingProductWithTag');
1422 $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, '', 'parent', 0, 0, 1);
1423 $moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"').$form->selectarray('search_product_category', $cate_arbo, $search_product_category, $tmptitle, 0, 0, '', 0, 0, 0, '', 'maxwidth300 widthcentpercentminusx', 1);
1424 $moreforfilter .= '</div>';
1425 }
1426 // alert on late date
1427 $moreforfilter .= '<div class="divsearchfield valignmiddle" title="'.$langs->trans("Alert").' '.$langs->trans("Late").'">';
1428 $moreforfilter .= '<label class="valignmiddle" for="search_option">'.$langs->trans('Alert').'</label> <input type="checkbox" class="valignmiddle" id="search_option" name="search_option" value="'.(($search_status == '3,4') ? 'recv_late' : 'late').'"'.((array_search($search_option, array('late','recv_late')) !== false) ? ' checked' : '').'>';
1429 $moreforfilter .= '</div>';
1430 $parameters = array();
1431 $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1432 if (empty($reshook)) {
1433 $moreforfilter .= $hookmanager->resPrint;
1434 } else {
1435 $moreforfilter = $hookmanager->resPrint;
1436 }
1437
1438 if (!empty($moreforfilter)) {
1439 print '<div class="liste_titre liste_titre_bydiv centpercent">';
1440 print $moreforfilter;
1441 print '</div>';
1442 }
1443
1444 $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
1445 $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, $conf->main_checkbox_left_column); // This also change content of $arrayfields
1446 $selectedfields .= $form->showCheckAddButtons('checkforselect', 1);
1447
1448 if (GETPOSTINT('autoselectall')) {
1449 $selectedfields .= '<script>';
1450 $selectedfields .= ' $(document).ready(function() {';
1451 $selectedfields .= ' console.log("Autoclick on checkforselects");';
1452 $selectedfields .= ' $("#checkforselects").click();';
1453 $selectedfields .= ' $("#massaction").val("createbills").change();';
1454 $selectedfields .= ' });';
1455 $selectedfields .= '</script>';
1456 }
1457
1458 print '<div class="div-table-responsive">';
1459 print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
1460
1461 print '<tr class="liste_titre_filter">';
1462 // Action column
1463 if ($conf->main_checkbox_left_column) {
1464 print '<td class="liste_titre middle">';
1465 $searchpicto = $form->showFilterButtons('left');
1466 print $searchpicto;
1467 print '</td>';
1468 }
1469 // Ref
1470 if (!empty($arrayfields['cf.ref']['checked'])) {
1471 print '<td class="liste_titre"><input size="8" type="text" class="flat maxwidth75" name="search_ref" value="'.$search_ref.'"></td>';
1472 }
1473 // Ref customer
1474 if (!empty($arrayfields['cf.ref_supplier']['checked'])) {
1475 print '<td class="liste_titre"><input type="text" class="flat maxwidth75" name="search_refsupp" value="'.$search_refsupp.'"></td>';
1476 }
1477 // Project ref
1478 if (!empty($arrayfields['cf.fk_projet']['checked'])) {
1479 print '<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_project_ref" value="'.$search_project_ref.'"></td>';
1480 }
1481 // Request author
1482 if (!empty($arrayfields['u.login']['checked'])) {
1483 print '<td class="liste_titre">';
1484 print '<input type="text" class="flat" size="6" name="search_request_author" value="'.$search_request_author.'">';
1485 print '</td>';
1486 }
1487 // Thirpdarty
1488 if (!empty($arrayfields['cf.fk_soc']['checked'])) {
1489 print '<td class="liste_titre"><input type="text" size="6" class="flat" name="search_company" value="'.$search_company.'"></td>';
1490 }
1491 // Alias
1492 if (!empty($arrayfields['s.name_alias']['checked'])) {
1493 print '<td class="liste_titre"><input type="text" size="6" class="flat" name="search_company_alias" value="'.$search_company_alias.'"></td>';
1494 }
1495 // Town
1496 if (!empty($arrayfields['s.town']['checked'])) {
1497 print '<td class="liste_titre"><input class="flat maxwidth50" type="text" name="search_town" value="'.$search_town.'"></td>';
1498 }
1499 // Zip
1500 if (!empty($arrayfields['s.zip']['checked'])) {
1501 print '<td class="liste_titre"><input class="flat maxwidth50" type="text" name="search_zip" value="'.$search_zip.'"></td>';
1502 }
1503 // State
1504 if (!empty($arrayfields['state.nom']['checked'])) {
1505 print '<td class="liste_titre">';
1506 print '<input class="flat maxwidth50" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).'">';
1507 print '</td>';
1508 }
1509 // Country
1510 if (!empty($arrayfields['country.code_iso']['checked'])) {
1511 print '<td class="liste_titre center">';
1512 print $form->select_country($search_country, 'search_country', '', 0, 'minwidth100imp maxwidth100');
1513 print '</td>';
1514 }
1515 // Company type
1516 if (!empty($arrayfields['typent.code']['checked'])) {
1517 print '<td class="liste_titre maxwidthonsmartphone center">';
1518 print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 1, 0, 0, '', 0, 0, 0, getDolGlobalString('SOCIETE_SORT_ON_TYPEENT', 'ASC'), '', 1);
1519 print '</td>';
1520 }
1521 // Date order
1522 if (!empty($arrayfields['cf.date_commande']['checked'])) {
1523 print '<td class="liste_titre center">';
1524 print '<div class="nowrapfordate">';
1525 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'));
1526 print '</div>';
1527 print '<div class="nowrapfordate">';
1528 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'));
1529 print '</div>';
1530 print '</td>';
1531 }
1532 // Date delivery
1533 if (!empty($arrayfields['cf.date_livraison']['checked'])) {
1534 print '<td class="liste_titre center">';
1535 print '<div class="nowrapfordate">';
1536 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'));
1537 print '</div>';
1538 print '<div class="nowrapfordate">';
1539 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'));
1540 print '</div>';
1541 print '</td>';
1542 }
1543 if (!empty($arrayfields['cf.total_ht']['checked'])) {
1544 // Amount
1545 print '<td class="liste_titre right">';
1546 print '<input class="flat" type="text" size="5" name="search_total_ht" value="'.$search_total_ht.'">';
1547 print '</td>';
1548 }
1549 if (!empty($arrayfields['cf.total_tva']['checked'])) {
1550 // Amount
1551 print '<td class="liste_titre right">';
1552 print '<input class="flat" type="text" size="5" name="search_total_tva" value="'.$search_total_tva.'">';
1553 print '</td>';
1554 }
1555 if (!empty($arrayfields['cf.total_ttc']['checked'])) {
1556 // Amount
1557 print '<td class="liste_titre right">';
1558 print '<input class="flat" type="text" size="5" name="search_total_ttc" value="'.$search_total_ttc.'">';
1559 print '</td>';
1560 }
1561 if (!empty($arrayfields['cf.multicurrency_code']['checked'])) {
1562 // Currency
1563 print '<td class="liste_titre">';
1564 print $form->selectMultiCurrency($search_multicurrency_code, 'search_multicurrency_code', 1);
1565 print '</td>';
1566 }
1567 if (!empty($arrayfields['cf.multicurrency_tx']['checked'])) {
1568 // Currency rate
1569 print '<td class="liste_titre">';
1570 print '<input class="flat" type="text" size="4" name="search_multicurrency_tx" value="'.dol_escape_htmltag($search_multicurrency_tx).'">';
1571 print '</td>';
1572 }
1573 if (!empty($arrayfields['cf.multicurrency_total_ht']['checked'])) {
1574 // Amount
1575 print '<td class="liste_titre right">';
1576 print '<input class="flat" type="text" size="4" name="search_multicurrency_montant_ht" value="'.dol_escape_htmltag($search_multicurrency_montant_ht).'">';
1577 print '</td>';
1578 }
1579 if (!empty($arrayfields['cf.multicurrency_total_tva']['checked'])) {
1580 // Amount
1581 print '<td class="liste_titre right">';
1582 print '<input class="flat" type="text" size="4" name="search_multicurrency_montant_tva" value="'.dol_escape_htmltag($search_multicurrency_montant_tva).'">';
1583 print '</td>';
1584 }
1585 if (!empty($arrayfields['cf.multicurrency_total_ttc']['checked'])) {
1586 // Amount
1587 print '<td class="liste_titre right">';
1588 print '<input class="flat" type="text" size="4" name="search_multicurrency_montant_ttc" value="'.dol_escape_htmltag($search_multicurrency_montant_ttc).'">';
1589 print '</td>';
1590 }
1591 // Extra fields
1592 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
1593
1594 // Fields from hook
1595 $parameters = array('arrayfields' => $arrayfields);
1596 $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
1597 print $hookmanager->resPrint;
1598 // Date creation
1599 if (!empty($arrayfields['cf.date_creation']['checked'])) {
1600 print '<td class="liste_titre">';
1601 print '</td>';
1602 }
1603 // Date modification
1604 if (!empty($arrayfields['cf.tms']['checked'])) {
1605 print '<td class="liste_titre">';
1606 print '</td>';
1607 }
1608 // Billed
1609 if (!empty($arrayfields['cf.billed']['checked'])) {
1610 print '<td class="liste_titre center parentonrightofpage">';
1611 print $form->selectyesno('billed', $billed, 1, false, 1, 1, 'search_status width100 onrightofpage');
1612 print '</td>';
1613 }
1614 // Status
1615 if (!empty($arrayfields['cf.fk_statut']['checked'])) {
1616 print '<td class="liste_titre center parentonrightofpage">';
1617 $formorder->selectSupplierOrderStatus($search_status, 1, 'search_status', 'search_status width125 onrightofpage');
1618 print '</td>';
1619 }
1620 // Date valid
1621 if (!empty($arrayfields['cf.date_valid']['checked'])) {
1622 print '<td class="liste_titre center">';
1623 print '<div class="nowrapfordate">';
1624 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'));
1625 print '</div>';
1626 print '<div class="nowrapfordate">';
1627 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'));
1628 print '</div>';
1629 print '</td>';
1630 }
1631 // Date approve
1632 if (!empty($arrayfields['cf.date_approve']['checked'])) {
1633 print '<td class="liste_titre center">';
1634 print '<div class="nowrapfordate">';
1635 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'));
1636 print '</div>';
1637 print '<div class="nowrapfordate">';
1638 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'));
1639 print '</div>';
1640 print '</td>';
1641 }
1642 if (!empty($arrayfields['cf.note_public']['checked'])) {
1643 // Note public
1644 print '<td class="liste_titre">';
1645 print '<input class="flat maxwidth75" type="text" name="search_note_public" value="'.dol_escape_htmltag($search_note_public).'">';
1646 print '</td>';
1647 }
1648 if (!empty($arrayfields['cf.note_private']['checked'])) {
1649 // Note private
1650 print '<td class="liste_titre">';
1651 print '<input class="flat maxwidth75" type="text" name="search_note_private" value="'.dol_escape_htmltag($search_note_private).'">';
1652 print '</td>';
1653 }
1654 // Action column
1655 if (!$conf->main_checkbox_left_column) {
1656 print '<td class="liste_titre center">';
1657 $searchpicto = $form->showFilterButtons();
1658 print $searchpicto;
1659 print '</td>';
1660 }
1661
1662 print "</tr>\n";
1663
1664 $totalarray = array();
1665 $totalarray['nbfield'] = 0;
1666
1667 // Fields title
1668 print '<tr class="liste_titre">';
1669 if ($conf->main_checkbox_left_column) {
1670 print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
1671 $totalarray['nbfield']++;
1672 }
1673 if (!empty($arrayfields['cf.ref']['checked'])) {
1674 print_liste_field_titre($arrayfields['cf.ref']['label'], $_SERVER["PHP_SELF"], "cf.ref", "", $param, '', $sortfield, $sortorder);
1675 $totalarray['nbfield']++;
1676 }
1677 if (!empty($arrayfields['cf.ref_supplier']['checked'])) {
1678 print_liste_field_titre($arrayfields['cf.ref_supplier']['label'], $_SERVER["PHP_SELF"], "cf.ref_supplier", "", $param, '', $sortfield, $sortorder, 'tdoverflowmax100imp ');
1679 $totalarray['nbfield']++;
1680 }
1681 if (!empty($arrayfields['cf.fk_projet']['checked'])) {
1682 print_liste_field_titre($arrayfields['cf.fk_projet']['label'], $_SERVER["PHP_SELF"], "p.ref", "", $param, '', $sortfield, $sortorder);
1683 $totalarray['nbfield']++;
1684 }
1685 if (!empty($arrayfields['u.login']['checked'])) {
1686 print_liste_field_titre($arrayfields['u.login']['label'], $_SERVER["PHP_SELF"], "u.login", "", $param, '', $sortfield, $sortorder);
1687 $totalarray['nbfield']++;
1688 }
1689 if (!empty($arrayfields['cf.fk_soc']['checked'])) {
1690 print_liste_field_titre($arrayfields['cf.fk_soc']['label'], $_SERVER["PHP_SELF"], "s.nom", "", $param, '', $sortfield, $sortorder);
1691 $totalarray['nbfield']++;
1692 }
1693 if (!empty($arrayfields['s.name_alias']['checked'])) {
1694 // @phan-suppress-next-line PhanTypeInvalidDimOffset
1695 print_liste_field_titre($arrayfields['s.name_alias']['label'], $_SERVER["PHP_SELF"], "s.name_alias", "", $param, '', $sortfield, $sortorder);
1696 $totalarray['nbfield']++;
1697 }
1698 if (!empty($arrayfields['s.town']['checked'])) {
1699 print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], 's.town', '', $param, '', $sortfield, $sortorder);
1700 $totalarray['nbfield']++;
1701 }
1702 if (!empty($arrayfields['s.zip']['checked'])) {
1703 print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], 's.zip', '', $param, '', $sortfield, $sortorder);
1704 $totalarray['nbfield']++;
1705 }
1706 if (!empty($arrayfields['state.nom']['checked'])) {
1707 print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder);
1708 $totalarray['nbfield']++;
1709 }
1710 if (!empty($arrayfields['country.code_iso']['checked'])) {
1711 print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, '', $sortfield, $sortorder, 'center ');
1712 $totalarray['nbfield']++;
1713 }
1714 if (!empty($arrayfields['typent.code']['checked'])) {
1715 print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, '', $sortfield, $sortorder, 'center ');
1716 $totalarray['nbfield']++;
1717 }
1718 if (!empty($arrayfields['cf.fk_author']['checked'])) {
1719 print_liste_field_titre($arrayfields['cf.fk_author']['label'], $_SERVER["PHP_SELF"], "cf.fk_author", "", $param, '', $sortfield, $sortorder);
1720 $totalarray['nbfield']++;
1721 }
1722 if (!empty($arrayfields['cf.date_commande']['checked'])) {
1723 print_liste_field_titre($arrayfields['cf.date_commande']['label'], $_SERVER["PHP_SELF"], "cf.date_commande", "", $param, '', $sortfield, $sortorder, 'center ');
1724 $totalarray['nbfield']++;
1725 }
1726 if (!empty($arrayfields['cf.date_livraison']['checked'])) {
1727 print_liste_field_titre($arrayfields['cf.date_livraison']['label'], $_SERVER["PHP_SELF"], 'cf.date_livraison', '', $param, '', $sortfield, $sortorder, 'center ');
1728 $totalarray['nbfield']++;
1729 }
1730 if (!empty($arrayfields['cf.total_ht']['checked'])) {
1731 print_liste_field_titre($arrayfields['cf.total_ht']['label'], $_SERVER["PHP_SELF"], "cf.total_ht", "", $param, '', $sortfield, $sortorder, 'right ');
1732 $totalarray['nbfield']++;
1733 }
1734 if (!empty($arrayfields['cf.total_tva']['checked'])) {
1735 print_liste_field_titre($arrayfields['cf.total_tva']['label'], $_SERVER["PHP_SELF"], "cf.total_tva", "", $param, '', $sortfield, $sortorder, 'right ');
1736 $totalarray['nbfield']++;
1737 }
1738 if (!empty($arrayfields['cf.total_ttc']['checked'])) {
1739 print_liste_field_titre($arrayfields['cf.total_ttc']['label'], $_SERVER["PHP_SELF"], "cf.total_ttc", "", $param, '', $sortfield, $sortorder, 'right ');
1740 $totalarray['nbfield']++;
1741 }
1742 if (!empty($arrayfields['cf.multicurrency_code']['checked'])) {
1743 print_liste_field_titre($arrayfields['cf.multicurrency_code']['label'], $_SERVER['PHP_SELF'], 'cf.multicurrency_code', '', $param, '', $sortfield, $sortorder);
1744 $totalarray['nbfield']++;
1745 }
1746 if (!empty($arrayfields['cf.multicurrency_tx']['checked'])) {
1747 print_liste_field_titre($arrayfields['cf.multicurrency_tx']['label'], $_SERVER['PHP_SELF'], 'cf.multicurrency_tx', '', $param, '', $sortfield, $sortorder);
1748 $totalarray['nbfield']++;
1749 }
1750 if (!empty($arrayfields['cf.multicurrency_total_ht']['checked'])) {
1751 print_liste_field_titre($arrayfields['cf.multicurrency_total_ht']['label'], $_SERVER['PHP_SELF'], 'cf.multicurrency_total_ht', '', $param, 'class="right"', $sortfield, $sortorder);
1752 $totalarray['nbfield']++;
1753 }
1754 if (!empty($arrayfields['cf.multicurrency_total_tva']['checked'])) {
1755 print_liste_field_titre($arrayfields['cf.multicurrency_total_tva']['label'], $_SERVER['PHP_SELF'], 'cf.multicurrency_total_tva', '', $param, 'class="right"', $sortfield, $sortorder);
1756 $totalarray['nbfield']++;
1757 }
1758 if (!empty($arrayfields['cf.multicurrency_total_ttc']['checked'])) {
1759 print_liste_field_titre($arrayfields['cf.multicurrency_total_ttc']['label'], $_SERVER['PHP_SELF'], 'cf.multicurrency_total_ttc', '', $param, 'class="right"', $sortfield, $sortorder);
1760 $totalarray['nbfield']++;
1761 }
1762 // Extra fields
1763 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
1764 // Hook fields
1765 $parameters = array('arrayfields' => $arrayfields, 'param' => $param, 'sortfield' => $sortfield, 'sortorder' => $sortorder);
1766 $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
1767 print $hookmanager->resPrint;
1768 if (!empty($arrayfields['cf.date_creation']['checked'])) {
1769 print_liste_field_titre($arrayfields['cf.date_creation']['label'], $_SERVER["PHP_SELF"], "cf.date_creation", "", $param, '', $sortfield, $sortorder, 'center nowraponall ');
1770 $totalarray['nbfield']++;
1771 }
1772 if (!empty($arrayfields['cf.tms']['checked'])) {
1773 print_liste_field_titre($arrayfields['cf.tms']['label'], $_SERVER["PHP_SELF"], "cf.tms", "", $param, '', $sortfield, $sortorder, 'center nowraponall ');
1774 $totalarray['nbfield']++;
1775 }
1776 if (!empty($arrayfields['cf.billed']['checked'])) {
1777 print_liste_field_titre($arrayfields['cf.billed']['label'], $_SERVER["PHP_SELF"], 'cf.billed', '', $param, '', $sortfield, $sortorder, 'center ');
1778 $totalarray['nbfield']++;
1779 }
1780 if (!empty($arrayfields['cf.fk_statut']['checked'])) {
1781 print_liste_field_titre($arrayfields['cf.fk_statut']['label'], $_SERVER["PHP_SELF"], "cf.fk_statut", "", $param, '', $sortfield, $sortorder, 'center ');
1782 $totalarray['nbfield']++;
1783 }
1784 if (!empty($arrayfields['cf.date_valid']['checked'])) {
1785 print_liste_field_titre($arrayfields['cf.date_valid']['label'], $_SERVER["PHP_SELF"], "cf.date_valid", "", $param, '', $sortfield, $sortorder, 'center ');
1786 $totalarray['nbfield']++;
1787 }
1788 if (!empty($arrayfields['cf.date_approve']['checked'])) {
1789 print_liste_field_titre($arrayfields['cf.date_approve']['label'], $_SERVER["PHP_SELF"], 'cf.date_approve', '', $param, '', $sortfield, $sortorder, 'center ');
1790 $totalarray['nbfield']++;
1791 }
1792 if (!empty($arrayfields['cf.note_public']['checked'])) {
1793 print_liste_field_titre($arrayfields['cf.note_public']['label'], $_SERVER["PHP_SELF"], "cf.note_public", "", $param, '', $sortfield, $sortorder, 'center ');
1794 $totalarray['nbfield']++;
1795 }
1796 if (!empty($arrayfields['cf.note_private']['checked'])) {
1797 print_liste_field_titre($arrayfields['cf.note_private']['label'], $_SERVER["PHP_SELF"], "cf.note_private", "", $param, '', $sortfield, $sortorder, 'center ');
1798 $totalarray['nbfield']++;
1799 }
1800 if (!$conf->main_checkbox_left_column) {
1801 print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
1802 $totalarray['nbfield']++;
1803 }
1804 print "</tr>\n";
1805
1806 $total = 0;
1807 $subtotal = 0;
1808 $productstat_cache = array();
1809
1810 $userstatic = new User($db);
1811 $objectstatic = new CommandeFournisseur($db);
1812 $projectstatic = new Project($db);
1813
1814 $i = 0;
1815 $savnbfield = $totalarray['nbfield'];
1816 $totalarray = array('nbfield' => 0, 'val' => array(), 'pos' => array());
1817 $totalarray['val']['cf.total_ht'] = 0;
1818 $totalarray['val']['cf.total_ttc'] = 0;
1819 $totalarray['val']['cf.total_tva'] = 0;
1820
1821 $imaxinloop = ($limit ? min($num, $limit) : $num);
1822 while ($i < $imaxinloop) {
1823 $obj = $db->fetch_object($resql);
1824
1825 $notshippable = 0;
1826 $warning = 0;
1827 $text_info = '';
1828 $text_warning = '';
1829 $nbprod = 0;
1830
1831 $objectstatic->id = $obj->rowid;
1832 $objectstatic->ref = $obj->ref;
1833 $objectstatic->ref_supplier = $obj->ref_supplier;
1834 $objectstatic->socid = $obj->socid;
1835 $objectstatic->total_ht = $obj->total_ht;
1836 $objectstatic->total_tva = $obj->total_tva;
1837 $objectstatic->total_ttc = $obj->total_ttc;
1838 $objectstatic->date = $db->jdate($obj->date_commande);
1839 $objectstatic->date_commande = $db->jdate($obj->date_commande);
1840 $objectstatic->date_creation = $db->jdate($obj->date_creation);
1841 $objectstatic->delivery_date = $db->jdate($obj->delivery_date);
1842 $objectstatic->note_public = $obj->note_public;
1843 $objectstatic->note_private = $obj->note_private;
1844 $objectstatic->statut = $obj->fk_statut;
1845 $objectstatic->status = $obj->fk_statut;
1846
1847 if ($mode == 'kanban') {
1848 if ($i == 0) {
1849 print '<tr class="trkanban"><td colspan="'.$savnbfield.'">';
1850 print '<div class="box-flex-container kanban">';
1851 }
1852
1853 $thirdpartytmp->id = $obj->socid;
1854 $thirdpartytmp->name = $obj->name;
1855 $thirdpartytmp->email = $obj->email;
1856 $thirdpartytmp->name_alias = $obj->alias;
1857 $thirdpartytmp->client = $obj->client;
1858 $thirdpartytmp->fournisseur = $obj->fournisseur;
1859 // Output Kanban
1860 print $objectstatic->getKanbanView('', array('thirdparty' => $thirdpartytmp->getNomUrl(1, 'supplier', 0, 0, -1), 'selected' => in_array($objectstatic->id, $arrayofselected)));
1861 if ($i == ($imaxinloop - 1)) {
1862 print '</div>';
1863 print '</td></tr>';
1864 }
1865 } else {
1866 print '<tr class="oddeven row-with-select '.((getDolGlobalInt('MAIN_FINISHED_LINES_OPACITY') == 1 && $obj->billed == 1) ? 'opacitymedium' : '').'">';
1867 // Action column
1868 if ($conf->main_checkbox_left_column) {
1869 print '<td class="nowraponall center">';
1870 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
1871 $selected = 0;
1872 if (in_array($obj->rowid, $arrayofselected)) {
1873 $selected = 1;
1874 }
1875 print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
1876 }
1877 print '</td>';
1878 if (!$i) {
1879 $totalarray['nbfield']++;
1880 }
1881 }
1882 // Ref
1883 if (!empty($arrayfields['cf.ref']['checked'])) {
1884 print '<td class="nowraponall">';
1885
1886 // Picto + Ref
1887 print $objectstatic->getNomUrl(1, '', 0, -1, 1);
1888 // Other picto tool
1889 $filename = dol_sanitizeFileName($obj->ref);
1890 $filedir = getMultidirOutput($objectstatic).'/'.dol_sanitizeFileName($obj->ref);
1891 print $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir);
1892
1893 print '</td>'."\n";
1894 if (!$i) {
1895 $totalarray['nbfield']++;
1896 }
1897 }
1898 // Ref Supplier
1899 if (!empty($arrayfields['cf.ref_supplier']['checked'])) {
1900 print '<td class="tdoverflowmax150" title="'.dol_escape_htmltag($obj->ref_supplier).'">'.dol_escape_htmltag($obj->ref_supplier).'</td>'."\n";
1901 if (!$i) {
1902 $totalarray['nbfield']++;
1903 }
1904 }
1905 // Project
1906 if (!empty($arrayfields['cf.fk_projet']['checked'])) {
1907 $projectstatic->id = $obj->project_id;
1908 $projectstatic->ref = $obj->project_ref;
1909 $projectstatic->title = $obj->project_title;
1910 print '<td class="tdoverflowmax125">';
1911 if ($obj->project_id > 0) {
1912 print $projectstatic->getNomUrl(1);
1913 }
1914 print '</td>';
1915 if (!$i) {
1916 $totalarray['nbfield']++;
1917 }
1918 }
1919 // Author
1920 $userstatic->id = $obj->fk_user_author;
1921 $userstatic->lastname = $obj->lastname;
1922 $userstatic->firstname = $obj->firstname;
1923 $userstatic->login = $obj->login;
1924 $userstatic->photo = $obj->photo;
1925 $userstatic->email = $obj->user_email;
1926 $userstatic->status = $obj->user_status;
1927 if (!empty($arrayfields['u.login']['checked'])) {
1928 print '<td class="tdoverflowmax150">';
1929 if ($userstatic->id) {
1930 print $userstatic->getNomUrl(1);
1931 }
1932 print "</td>";
1933 if (!$i) {
1934 $totalarray['nbfield']++;
1935 }
1936 }
1937 // Thirdparty
1938 if (!empty($arrayfields['cf.fk_soc']['checked'])) {
1939 print '<td class="tdoverflowmax150">';
1940 $thirdpartytmp->id = $obj->socid;
1941 $thirdpartytmp->name = $obj->name;
1942 $thirdpartytmp->email = $obj->email;
1943 $thirdpartytmp->name_alias = $obj->alias;
1944 $thirdpartytmp->client = $obj->client;
1945 $thirdpartytmp->fournisseur = $obj->fournisseur;
1946 print $thirdpartytmp->getNomUrl(1, 'supplier', 0, 0, -1, empty($arrayfields['s.name_alias']['checked']) ? 0 : 1);
1947 print '</td>'."\n";
1948 if (!$i) {
1949 $totalarray['nbfield']++;
1950 }
1951 }
1952 // Alias
1953 if (!empty($arrayfields['s.name_alias']['checked'])) {
1954 print '<td class="tdoverflowmax150" title="'.dol_escape_htmltag($obj->alias).'">';
1955 print dol_escape_htmltag($obj->alias);
1956 print '</td>'."\n";
1957 if (!$i) {
1958 $totalarray['nbfield']++;
1959 }
1960 }
1961 // Town
1962 if (!empty($arrayfields['s.town']['checked'])) {
1963 print '<td class="tdoverflowmax100" title="'.dol_escape_htmltag($obj->town).'">';
1964 print dol_escape_htmltag($obj->town);
1965 print '</td>';
1966 if (!$i) {
1967 $totalarray['nbfield']++;
1968 }
1969 }
1970 // Zip
1971 if (!empty($arrayfields['s.zip']['checked'])) {
1972 print '<td class="tdoverflowmax100" title="'.dol_escape_htmltag($obj->zip).'">';
1973 print dol_escape_htmltag($obj->zip);
1974 print '</td>';
1975 if (!$i) {
1976 $totalarray['nbfield']++;
1977 }
1978 }
1979 // State
1980 if (!empty($arrayfields['state.nom']['checked'])) {
1981 print '<td class="tdoverflowmax100" title="'.dol_escape_htmltag($obj->state_name).'">'.dol_escape_htmltag($obj->state_name)."</td>\n";
1982 if (!$i) {
1983 $totalarray['nbfield']++;
1984 }
1985 }
1986 // Country
1987 if (!empty($arrayfields['country.code_iso']['checked'])) {
1988 print '<td class="center">';
1989 $tmparray = getCountry($obj->fk_pays, 'all');
1990 print $tmparray['label'];
1991 print '</td>';
1992 if (!$i) {
1993 $totalarray['nbfield']++;
1994 }
1995 }
1996 // Type ent
1997 if (!empty($arrayfields['typent.code']['checked'])) {
1998 print '<td class="center">';
1999 if (empty($typenArray)) {
2000 $typenArray = $formcompany->typent_array(1);
2001 }
2002 print $typenArray[$obj->typent_code];
2003 print '</td>';
2004 if (!$i) {
2005 $totalarray['nbfield']++;
2006 }
2007 }
2008
2009 // Order date
2010 if (!empty($arrayfields['cf.date_commande']['checked'])) {
2011 print '<td class="center">';
2012 print dol_print_date($db->jdate($obj->date_commande), 'day');
2013 if ($objectstatic->statut != $objectstatic::STATUS_ORDERSENT && $objectstatic->statut != $objectstatic::STATUS_RECEIVED_PARTIALLY) {
2014 if ($objectstatic->hasDelay()) {
2015 print ' '.img_picto($langs->trans("Late").' : '.$objectstatic->showDelay(), "warning");
2016 }
2017 }
2018 print '</td>';
2019 if (!$i) {
2020 $totalarray['nbfield']++;
2021 }
2022 }
2023 // Plannned date of delivery
2024 if (!empty($arrayfields['cf.date_livraison']['checked'])) {
2025 print '<td class="center">';
2026 print dol_print_date($db->jdate($obj->delivery_date), 'day');
2027 if ($objectstatic->statut == $objectstatic::STATUS_ORDERSENT || $objectstatic->statut == $objectstatic::STATUS_RECEIVED_PARTIALLY) {
2028 if ($objectstatic->hasDelay()) {
2029 print ' '.img_picto($langs->trans("Late").' : '.$objectstatic->showDelay(), "warning");
2030 }
2031 }
2032 print '</td>';
2033 if (!$i) {
2034 $totalarray['nbfield']++;
2035 }
2036 }
2037 // Amount HT
2038 if (!empty($arrayfields['cf.total_ht']['checked'])) {
2039 print '<td class="right"><span class="amount">'.price($obj->total_ht)."</span></td>\n";
2040 if (!$i) {
2041 $totalarray['nbfield']++;
2042 }
2043 if (!$i) {
2044 $totalarray['pos'][$totalarray['nbfield']] = 'cf.total_ht';
2045 }
2046 $totalarray['val']['cf.total_ht'] += $obj->total_ht;
2047 }
2048 // Amount VAT
2049 if (!empty($arrayfields['cf.total_tva']['checked'])) {
2050 print '<td class="right"><span class="amount">'.price($obj->total_tva)."</span></td>\n";
2051 if (!$i) {
2052 $totalarray['nbfield']++;
2053 }
2054 if (!$i) {
2055 $totalarray['pos'][$totalarray['nbfield']] = 'cf.total_tva';
2056 }
2057 $totalarray['val']['cf.total_tva'] += $obj->total_tva;
2058 }
2059 // Amount TTC
2060 if (!empty($arrayfields['cf.total_ttc']['checked'])) {
2061 print '<td class="right"><span class="amount">'.price($obj->total_ttc)."</span></td>\n";
2062 if (!$i) {
2063 $totalarray['nbfield']++;
2064 }
2065 if (!$i) {
2066 $totalarray['pos'][$totalarray['nbfield']] = 'cf.total_ttc';
2067 }
2068 $totalarray['val']['cf.total_ttc'] += $obj->total_ttc;
2069 }
2070
2071 // Currency
2072 if (!empty($arrayfields['cf.multicurrency_code']['checked'])) {
2073 print '<td class="nowrap">'.$obj->multicurrency_code.' - '.$langs->trans('Currency'.$obj->multicurrency_code)."</td>\n";
2074 if (!$i) {
2075 $totalarray['nbfield']++;
2076 }
2077 }
2078
2079 // Currency rate
2080 if (!empty($arrayfields['cf.multicurrency_tx']['checked'])) {
2081 print '<td class="nowrap">';
2082 $form->form_multicurrency_rate($_SERVER['PHP_SELF'].'?id='.$obj->rowid, $obj->multicurrency_tx, 'none', $obj->multicurrency_code);
2083 print "</td>\n";
2084 if (!$i) {
2085 $totalarray['nbfield']++;
2086 }
2087 }
2088 // Amount HT
2089 if (!empty($arrayfields['cf.multicurrency_total_ht']['checked'])) {
2090 print '<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_ht)."</span></td>\n";
2091 if (!$i) {
2092 $totalarray['nbfield']++;
2093 }
2094 }
2095 // Amount VAT
2096 if (!empty($arrayfields['cf.multicurrency_total_tva']['checked'])) {
2097 print '<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_tva)."</span></td>\n";
2098 if (!$i) {
2099 $totalarray['nbfield']++;
2100 }
2101 }
2102 // Amount TTC
2103 if (!empty($arrayfields['cf.multicurrency_total_ttc']['checked'])) {
2104 print '<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_ttc)."</span></td>\n";
2105 if (!$i) {
2106 $totalarray['nbfield']++;
2107 }
2108 }
2109
2110 // Extra fields
2111 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
2112 // Fields from hook
2113 $parameters = array('arrayfields' => $arrayfields, 'obj' => $obj, 'i' => $i, 'totalarray' => &$totalarray);
2114 $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook
2115 print $hookmanager->resPrint;
2116 // Date creation
2117 if (!empty($arrayfields['cf.date_creation']['checked'])) {
2118 print '<td class="center nowraponall">';
2119 print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser');
2120 print '</td>';
2121 if (!$i) {
2122 $totalarray['nbfield']++;
2123 }
2124 }
2125 // Date modification
2126 if (!empty($arrayfields['cf.tms']['checked'])) {
2127 print '<td class="center nowraponall">';
2128 print dol_print_date($db->jdate($obj->date_modification), 'dayhour', 'tzuser');
2129 print '</td>';
2130 if (!$i) {
2131 $totalarray['nbfield']++;
2132 }
2133 }
2134 // Billed
2135 if (!empty($arrayfields['cf.billed']['checked'])) {
2136 print '<td class="center">';
2137 if ($obj->billed) {
2138 print yn($obj->billed, $langs->trans("Billed"));
2139 }
2140 print '</td>';
2141 if (!$i) {
2142 $totalarray['nbfield']++;
2143 }
2144 }
2145 // Status
2146 if (!empty($arrayfields['cf.fk_statut']['checked'])) {
2147 print '<td class="center nowrap">'.$objectstatic->LibStatut($obj->fk_statut, 5, $obj->billed).'</td>';
2148 if (!$i) {
2149 $totalarray['nbfield']++;
2150 }
2151 }
2152
2153 // valid date
2154 if (!empty($arrayfields['cf.date_valid']['checked'])) {
2155 print '<td class="center">';
2156 print dol_print_date($db->jdate($obj->date_valid), 'day');
2157 print '</td>';
2158 if (!$i) {
2159 $totalarray['nbfield']++;
2160 }
2161 }
2162 // approve date
2163 if (!empty($arrayfields['cf.date_approve']['checked'])) {
2164 print '<td class="center">';
2165 print dol_print_date($db->jdate($obj->date_approve), 'day');
2166 print '</td>';
2167 if (!$i) {
2168 $totalarray['nbfield']++;
2169 }
2170 }
2171 // Note public
2172 if (!empty($arrayfields['cf.note_public']['checked'])) {
2173 print '<td class="sensiblehtmlcontent center">';
2174 print '<div class="small lineheightsmall twolinesmax-normallineheight">'.dolPrintHTML(dolGetFirstLineOfText($obj->note_public, 5)).'</div>';
2175 print '</td>';
2176 if (!$i) {
2177 $totalarray['nbfield']++;
2178 }
2179 }
2180
2181 // Note private
2182 if (!empty($arrayfields['cf.note_private']['checked'])) {
2183 print '<td class="sensiblehtmlcontent center">';
2184 print '<div class="small lineheightsmall twolinesmax-normallineheight">'.dolPrintHTML(dolGetFirstLineOfText($obj->note_private, 5)).'</div>';
2185 print '</td>';
2186 if (!$i) {
2187 $totalarray['nbfield']++;
2188 }
2189 }
2190
2191 // Action column
2192 if (!$conf->main_checkbox_left_column) {
2193 print '<td class="nowrap center">';
2194 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
2195 $selected = 0;
2196 if (in_array($obj->rowid, $arrayofselected)) {
2197 $selected = 1;
2198 }
2199 print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
2200 }
2201 print '</td>';
2202 if (!$i) {
2203 $totalarray['nbfield']++;
2204 }
2205 }
2206
2207 print "</tr>\n";
2208
2209 $total += $obj->total_ht;
2210 $subtotal += $obj->total_ht;
2211 }
2212 $i++;
2213 }
2214
2215 // Show total line
2216 include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
2217
2218 // If no record found
2219 if ($num == 0) {
2220 $colspan = 1;
2221 foreach ($arrayfields as $key => $val) {
2222 if (!empty($val['checked'])) {
2223 $colspan++;
2224 }
2225 }
2226 print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
2227 }
2228
2229 $db->free($resql);
2230
2231 $parameters = array('arrayfields' => $arrayfields, 'sql' => $sql);
2232 $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook
2233 print $hookmanager->resPrint;
2234
2235 print '</table>'."\n";
2236 print '</div>';
2237
2238 print '</form>'."\n";
2239
2240 $hidegeneratedfilelistifempty = 1;
2241 if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) {
2242 $hidegeneratedfilelistifempty = 0;
2243 }
2244
2245 // Show list of available documents
2246 $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
2247 $urlsource .= str_replace('&amp;', '&', $param);
2248
2249 $filedir = $diroutputmassaction;
2250 $genallowed = $permissiontoread;
2251 $delallowed = $permissiontoadd;
2252
2253 print $formfile->showdocuments('massfilesarea_supplier_order', '', $filedir, $urlsource, 0, (int) $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
2254} else {
2256}
2257
2258// End of page
2259llxFooter();
2260$db->close();
$id
Support class for third parties, contacts, members, users or resources.
Definition account.php:47
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
$totalarray
Definition list.php:497
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:91
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:73
Class to manage predefined suppliers products.
Class to manage absolute discounts.
Class to manage suppliers invoices.
Class to manage forms for categories.
Class to build HTML component for third parties management Only common components are here.
Class to offer components to list and upload files.
Class to manage generation of HTML components Only common components must be here.
Class to manage HTML output components for orders Before adding component here, check they are not in...
Class to help generate other html components Only common components are here.
Class to manage suppliers.
Class to manage projects.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage Dolibarr users.
getCountry($searchkey, $withcode='', $dbtouse=null, $outputlangs=null, $entconv=1, $searchlabel='')
Return country label, code or id from an id, code or label.
global $mysoc
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
$date_start
Variables from include:
dol_now($mode='gmt')
Return date for now.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
print_liste_field_titre($name, $file="", $field="", $begin="", $param="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $selectlimitsuffix=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dolGetFirstLineOfText($text, $nboflines=1, $charset='UTF-8')
Return first line of text.
getMultidirTemp($object, $module='', $forobject=0)
Return the full path of the directory where a module (or an object of a module) stores its temporary ...
dol_eval($s, $returnvalue=1, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
GETPOSTISARRAY($paramname, $method=0)
Return true if the parameter $paramname is submit from a POST OR GET as an array.
natural_search($fields, $value, $mode=0, $nofirstand=0, $sqltoadd='')
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by the value of a given key, which produces ascending (default) or descending out...
getMultidirOutput($object, $module='', $forobject=0, $mode='output')
Return the full path of the directory where a module (or an object of a module) stores its files.
dol_concatdesc($text1, $text2, $forxml=false, $invert=false)
Concat 2 descriptions with a new line between them (second operand after first one with appropriate n...
yn($yesno, $format=1, $color=0)
Return yes or no in current language.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
print $langs trans("Show") . '< td style="' . $timeColor . '" align="center"> s</td > badge status0 badge status4 badge status3 Error badge status8< td align="center">< span class="badge ' . $badge . '"></span ></td >< td align="center">< a href="#" class="button button-small" onclick="openLogModal(this)" data-req="' . dol_escape_htmltag($reqSafe) . '" data-res="' . dol_escape_htmltag($resSafe) . '" data-err="' . dol_escape_htmltag($errSafe) . '">< span class="fa fa-search-plus"></span ></a ></td ></tr >< tr >< td colspan="' . $colspan . '" class="opacitymedium"></td ></tr ></table ></div ></form > logModal none logModal none s a JSON string
buildzip.php
restrictedArea(User $user, $features, $object=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.