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