dolibarr 19.0.4
list.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2004-2019 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
5 * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
6 * Copyright (C) 2012 Juanjo Menent <jmenent@2byte.es>
7 * Copyright (C) 2013 Christophe Battarel <christophe.battarel@altairis.fr>
8 * Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr>
9 * Copyright (C) 2015-2018 Frédéric France <frederic.france@netlogic.fr>
10 * Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
11 * Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
12 * Copyright (C) 2016-2023 Ferran Marcet <fmarcet@2byte.es>
13 * Copyright (C) 2018-2023 Charlene Benke <charlene@patas-monkey.com>
14 * Copyright (C) 2021 Anthony Berton <anthony.berton@bb2a.fr>
15 * Copyright (C) 2024 William Mead <william.mead@manchenumerique.fr>
16 *
17 * This program is free software; you can redistribute it and/or modify
18 * it under the terms of the GNU General Public License as published by
19 * the Free Software Foundation; either version 3 of the License, or
20 * (at your option) any later version.
21 *
22 * This program is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
26 *
27 * You should have received a copy of the GNU General Public License
28 * along with this program. If not, see <https://www.gnu.org/licenses/>.
29 */
30
38// Load Dolibarr environment
39require '../main.inc.php';
40require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
41require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
42require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php';
43require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
44require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
45require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
46if (isModEnabled('margin')) {
47 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formmargin.class.php';
48}
49require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
50require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
51require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
52require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
53
54// Load translation files required by the page
55$langs->loadLangs(array('orders', 'sendings', 'deliveries', 'companies', 'compta', 'bills', 'stocks', 'products'));
56
57// Get Parameters
58$action = GETPOST('action', 'aZ09');
59$massaction = GETPOST('massaction', 'alpha');
60$show_files = GETPOST('show_files', 'int');
61$confirm = GETPOST('confirm', 'alpha');
62$toselect = GETPOST('toselect', 'array');
63$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'orderlist';
64$mode = GETPOST('mode', 'alpha');
65
66// Search Parameters
67$search_datecloture_start = GETPOST('search_datecloture_start', 'int');
68if (empty($search_datecloture_start)) {
69 $search_datecloture_start = dol_mktime(0, 0, 0, GETPOST('search_datecloture_startmonth', 'int'), GETPOST('search_datecloture_startday', 'int'), GETPOST('search_datecloture_startyear', 'int'));
70}
71$search_datecloture_end = GETPOST('search_datecloture_end', 'int');
72if (empty($search_datecloture_end)) {
73 $search_datecloture_end = dol_mktime(23, 59, 59, GETPOST('search_datecloture_endmonth', 'int'), GETPOST('search_datecloture_endday', 'int'), GETPOST('search_datecloture_endyear', 'int'));
74}
75$search_dateorder_start = dol_mktime(0, 0, 0, GETPOST('search_dateorder_start_month', 'int'), GETPOST('search_dateorder_start_day', 'int'), GETPOST('search_dateorder_start_year', 'int'));
76$search_dateorder_end = dol_mktime(23, 59, 59, GETPOST('search_dateorder_end_month', 'int'), GETPOST('search_dateorder_end_day', 'int'), GETPOST('search_dateorder_end_year', 'int'));
77$search_datedelivery_start = dol_mktime(0, 0, 0, GETPOST('search_datedelivery_start_month', 'int'), GETPOST('search_datedelivery_start_day', 'int'), GETPOST('search_datedelivery_start_year', 'int'));
78$search_datedelivery_end = dol_mktime(23, 59, 59, GETPOST('search_datedelivery_end_month', 'int'), GETPOST('search_datedelivery_end_day', 'int'), GETPOST('search_datedelivery_end_year', 'int'));
79
80$socid = GETPOST('socid', 'int');
81$search_all = trim((GETPOST('search_all', 'alphanohtml') != '') ? GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml'));
82$search_product_category = GETPOST('search_product_category', 'int');
83$search_ref = GETPOST('search_ref', 'alpha') != '' ? GETPOST('search_ref', 'alpha') : GETPOST('sref', 'alpha');
84$search_ref_customer = GETPOST('search_ref_customer', 'alpha');
85$search_company = GETPOST('search_company', 'alpha');
86$search_company_alias = GETPOST('search_company_alias', 'alpha');
87$search_parent_name = trim(GETPOST('search_parent_name', 'alphanohtml'));
88$search_town = GETPOST('search_town', 'alpha');
89$search_zip = GETPOST('search_zip', 'alpha');
90$search_state = GETPOST('search_state', 'alpha');
91$search_country = GETPOST('search_country', 'int');
92$search_type_thirdparty = GETPOST('search_type_thirdparty', 'int');
93$search_user = GETPOST('search_user', 'int');
94$search_sale = GETPOST('search_sale', 'int');
95$search_total_ht = GETPOST('search_total_ht', 'alpha');
96$search_total_vat = GETPOST('search_total_vat', 'alpha');
97$search_total_ttc = GETPOST('search_total_ttc', 'alpha');
98$search_warehouse = GETPOST('search_warehouse', 'int');
99
100$search_multicurrency_code = GETPOST('search_multicurrency_code', 'alpha');
101$search_multicurrency_tx = GETPOST('search_multicurrency_tx', 'alpha');
102$search_multicurrency_montant_ht = GETPOST('search_multicurrency_montant_ht', 'alpha');
103$search_multicurrency_montant_vat = GETPOST('search_multicurrency_montant_vat', 'alpha');
104$search_multicurrency_montant_ttc = GETPOST('search_multicurrency_montant_ttc', 'alpha');
105
106$search_login = GETPOST('search_login', 'alpha');
107$search_categ_cus = GETPOST("search_categ_cus", 'int');
108$optioncss = GETPOST('optioncss', 'alpha');
109$search_billed = GETPOST('search_billed', 'int');
110$search_status = GETPOST('search_status', 'int');
111$search_project_ref = GETPOST('search_project_ref', 'alpha');
112$search_project = GETPOST('search_project', 'alpha');
113$search_shippable = GETPOST('search_shippable', 'aZ09');
114
115$search_fk_cond_reglement = GETPOST('search_fk_cond_reglement', 'int');
116$search_fk_shipping_method = GETPOST('search_fk_shipping_method', 'int');
117$search_fk_mode_reglement = GETPOST('search_fk_mode_reglement', 'int');
118$search_fk_input_reason = GETPOST('search_fk_input_reason', 'int');
119$search_option = GETPOST('search_option', 'alpha');
120if ($search_option == 'late') {
121 $search_status = '-2';
122}
123
124$diroutputmassaction = $conf->commande->multidir_output[$conf->entity].'/temp/massgeneration/'.$user->id;
125
126// Load variable for pagination
127$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
128$sortfield = GETPOST('sortfield', 'aZ09comma');
129$sortorder = GETPOST('sortorder', 'aZ09comma');
130$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
131if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
132 // If $page is not defined, or '' or -1 or if we click on clear filters
133 $page = 0;
134}
135$offset = $limit * $page;
136$pageprev = $page - 1;
137$pagenext = $page + 1;
138if (!$sortfield) {
139 $sortfield = 'c.ref';
140}
141if (!$sortorder) {
142 $sortorder = 'DESC';
143}
144
145$show_shippable_command = GETPOST('show_shippable_command', 'aZ09');
146
147// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
148$object = new Commande($db);
149$hookmanager->initHooks(array('orderlist'));
150$extrafields = new ExtraFields($db);
151
152// fetch optionals attributes and labels
153$extrafields->fetch_name_optionals_label($object->table_element);
154$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
155
156// List of fields to search into when doing a "search in all"
157$fieldstosearchall = array(
158 'c.ref'=>'Ref',
159 'c.ref_client'=>'RefCustomerOrder',
160 'pd.description'=>'Description',
161 's.nom'=>"ThirdParty",
162 's.name_alias'=>"AliasNameShort",
163 's.zip'=>"Zip",
164 's.town'=>"Town",
165 'c.note_public'=>'NotePublic',
166);
167if (empty($user->socid)) {
168 $fieldstosearchall["c.note_private"] = "NotePrivate";
169}
170
171$checkedtypetiers = 0;
172$arrayfields = array(
173 'c.ref'=>array('label'=>"Ref", 'checked'=>1, 'position'=>5),
174 'c.ref_client'=>array('label'=>"RefCustomerOrder", 'checked'=>-1, 'position'=>10),
175 'p.ref'=>array('label'=>"ProjectRef", 'checked'=>-1, 'enabled'=>(!isModEnabled('project') ? 0 : 1), 'position'=>20),
176 'p.title'=>array('label'=>"ProjectLabel", 'checked'=>0, 'enabled'=>(!isModEnabled('project') ? 0 : 1), 'position'=>25),
177 's.nom'=>array('label'=>"ThirdParty", 'checked'=>1, 'position'=>30),
178 's.name_alias'=>array('label'=>"AliasNameShort", 'checked'=>-1, 'position'=>31),
179 's2.nom'=>array('label'=>'ParentCompany', 'position'=>32, 'checked'=>0),
180 's.town'=>array('label'=>"Town", 'checked'=>-1, 'position'=>35),
181 's.zip'=>array('label'=>"Zip", 'checked'=>-1, 'position'=>40),
182 'state.nom'=>array('label'=>"StateShort", 'checked'=>0, 'position'=>45),
183 'country.code_iso'=>array('label'=>"Country", 'checked'=>0, 'position'=>50),
184 'typent.code'=>array('label'=>"ThirdPartyType", 'checked'=>$checkedtypetiers, 'position'=>55),
185 'c.date_commande'=>array('label'=>"OrderDateShort", 'checked'=>1, 'position'=>60, 'csslist'=>'nowraponall'),
186 'c.date_delivery'=>array('label'=>"DateDeliveryPlanned", 'checked'=>1, 'enabled'=>!getDolGlobalString('ORDER_DISABLE_DELIVERY_DATE'), 'position'=>65, 'csslist'=>'nowraponall'),
187 'c.fk_shipping_method'=>array('label'=>"SendingMethod", 'checked'=>-1, 'position'=>66 , 'enabled'=>isModEnabled("expedition")),
188 'c.fk_cond_reglement'=>array('label'=>"PaymentConditionsShort", 'checked'=>-1, 'position'=>67),
189 'c.fk_mode_reglement'=>array('label'=>"PaymentMode", 'checked'=>-1, 'position'=>68),
190 'c.fk_input_reason'=>array('label'=>"Origin", 'checked'=>-1, 'position'=>69),
191 'c.total_ht'=>array('label'=>"AmountHT", 'checked'=>1, 'position'=>75),
192 'c.total_vat'=>array('label'=>"AmountVAT", 'checked'=>0, 'position'=>80),
193 'c.total_ttc'=>array('label'=>"AmountTTC", 'checked'=>0, 'position'=>85),
194 'c.multicurrency_code'=>array('label'=>'Currency', 'checked'=>0, 'enabled'=>(!isModEnabled("multicurrency") ? 0 : 1), 'position'=>90),
195 'c.multicurrency_tx'=>array('label'=>'CurrencyRate', 'checked'=>0, 'enabled'=>(!isModEnabled("multicurrency") ? 0 : 1), 'position'=>95),
196 'c.multicurrency_total_ht'=>array('label'=>'MulticurrencyAmountHT', 'checked'=>0, 'enabled'=>(!isModEnabled("multicurrency") ? 0 : 1), 'position'=>100),
197 'c.multicurrency_total_vat'=>array('label'=>'MulticurrencyAmountVAT', 'checked'=>0, 'enabled'=>(!isModEnabled("multicurrency") ? 0 : 1), 'position'=>105),
198 'c.multicurrency_total_ttc'=>array('label'=>'MulticurrencyAmountTTC', 'checked'=>0, 'enabled'=>(!isModEnabled("multicurrency") ? 0 : 1), 'position'=>110),
199 'u.login'=>array('label'=>"Author", 'checked'=>1, 'position'=>115),
200 'sale_representative'=>array('label'=>"SaleRepresentativesOfThirdParty", 'checked'=>0, 'position'=>116),
201 'total_pa' => array('label' => (getDolGlobalString('MARGIN_TYPE') == '1' ? 'BuyingPrice' : 'CostPrice'), 'checked' => 0, 'position' => 300, 'enabled' => (!isModEnabled('margin') || !$user->hasRight("margins", "liretous") ? 0 : 1)),
202 'total_margin' => array('label' => 'Margin', 'checked' => 0, 'position' => 301, 'enabled' => (!isModEnabled('margin') || !$user->hasRight("margins", "liretous") ? 0 : 1)),
203 'total_margin_rate' => array('label' => 'MarginRate', 'checked' => 0, 'position' => 302, 'enabled' => (!isModEnabled('margin') || !$user->hasRight("margins", "liretous") || !getDolGlobalString('DISPLAY_MARGIN_RATES') ? 0 : 1)),
204 'total_mark_rate' => array('label' => 'MarkRate', 'checked' => 0, 'position' => 303, 'enabled' => (!isModEnabled('margin') || !$user->hasRight("margins", "liretous") || !getDolGlobalString('DISPLAY_MARK_RATES') ? 0 : 1)),
205 'c.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>120),
206 'c.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>125),
207 'c.date_cloture'=>array('label'=>"DateClosing", 'checked'=>0, 'position'=>130),
208 'c.note_public'=>array('label'=>'NotePublic', 'checked'=>0, 'enabled'=>(!getDolGlobalInt('MAIN_LIST_HIDE_PUBLIC_NOTES')), 'position'=>135),
209 'c.note_private'=>array('label'=>'NotePrivate', 'checked'=>0, 'enabled'=>(!getDolGlobalInt('MAIN_LIST_HIDE_PRIVATE_NOTES')), 'position'=>140),
210 'shippable'=>array('label'=>"Shippable", 'checked'=>1,'enabled'=>(isModEnabled("expedition")), 'position'=>990),
211 'c.facture'=>array('label'=>"Billed", 'checked'=>1, 'enabled'=>(!getDolGlobalString('WORKFLOW_BILL_ON_SHIPMENT')), 'position'=>995),
212 'c.import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'position'=>999),
213 'c.fk_statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000)
214);
215
216// Extra fields
217include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
218
219$object->fields = dol_sort_array($object->fields, 'position');
220//$arrayfields['anotherfield'] = array('type'=>'integer', 'label'=>'AnotherField', 'checked'=>1, 'enabled'=>1, 'position'=>90, 'csslist'=>'right');
221$arrayfields = dol_sort_array($arrayfields, 'position');
222
223if (!$user->hasRight('societe', 'client', 'voir')) {
224 $search_sale = $user->id;
225}
226
227// Security check
228$id = (GETPOST('orderid') ? GETPOST('orderid', 'int') : GETPOST('id', 'int'));
229if ($user->socid) {
230 $socid = $user->socid;
231}
232$result = restrictedArea($user, 'commande', $id, '');
233
234$error = 0;
235
236
237/*
238 * Actions
239 */
240
241if (GETPOST('cancel', 'alpha')) {
242 $action = 'list';
243 $massaction = '';
244}
245if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createbills') {
246 $massaction = '';
247}
248
249$parameters = array('socid'=>$socid, 'arrayfields'=>&$arrayfields);
250$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
251if ($reshook < 0) {
252 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
253}
254
255if (empty($reshook)) {
256 // Selection of new fields
257 include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
258
259 // Purge search criteria
260 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
261 $search_user = '';
262 $search_sale = '';
263 $search_product_category = '';
264 $search_ref = '';
265 $search_ref_customer = '';
266 $search_company = '';
267 $search_company_alias = '';
268 $search_parent_name = '';
269 $search_town = '';
270 $search_zip = "";
271 $search_state = "";
272 $search_type = '';
273 $search_country = '';
274 $search_type_thirdparty = '';
275 $search_total_ht = '';
276 $search_total_vat = '';
277 $search_total_ttc = '';
278 $search_warehouse = '';
279 $search_multicurrency_code = '';
280 $search_multicurrency_tx = '';
281 $search_multicurrency_montant_ht = '';
282 $search_multicurrency_montant_vat = '';
283 $search_multicurrency_montant_ttc = '';
284 $search_login = '';
285 $search_dateorder_start = '';
286 $search_dateorder_end = '';
287 $search_datedelivery_start = '';
288 $search_datedelivery_end = '';
289 $search_project_ref = '';
290 $search_project = '';
291 $search_status = '';
292 $search_billed = '';
293 $toselect = array();
294 $search_array_options = array();
295 $search_categ_cus = 0;
296 $search_datecloture_start = '';
297 $search_datecloture_end = '';
298 $search_fk_cond_reglement = '';
299 $search_fk_shipping_method = '';
300 $search_fk_mode_reglement = '';
301 $search_fk_input_reason = '';
302 $search_option = '';
303 }
304 if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')
305 || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) {
306 $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation
307 }
308
309 // Mass actions
310 $objectclass = 'Commande';
311 $objectlabel = 'Orders';
312 $permissiontoread = $user->hasRight("commande", "lire");
313 $permissiontoadd = $user->hasRight("commande", "creer");
314 $permissiontodelete = $user->hasRight("commande", "supprimer");
315 if (getDolGlobalString('MAIN_USE_ADVANCED_PERMS')) {
316 $permissiontovalidate = $user->hasRight("commande", "order_advance", "validate");
317 $permissiontoclose = $user->hasRight("commande", "order_advance", "close");
318 $permissiontocancel = $user->hasRight("commande", "order_advance", "annuler");
319 $permissiontosendbymail = $user->hasRight("commande", "order_advance", "send");
320 } else {
321 $permissiontovalidate = $user->hasRight("commande", "creer");
322 $permissiontoclose = $user->hasRight("commande", "creer");
323 $permissiontocancel = $user->hasRight("commande", "creer");
324 $permissiontosendbymail = $user->hasRight("commande", "creer");
325 }
326 $uploaddir = $conf->commande->multidir_output[$conf->entity];
327 $triggersendname = 'ORDER_SENTBYMAIL';
328 $year="";
329 $month="";
330 include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
331
332 if ($massaction == 'confirm_createbills') { // Create bills from orders.
333 $orders = GETPOST('toselect', 'array');
334 $createbills_onebythird = GETPOST('createbills_onebythird', 'int');
335 $validate_invoices = GETPOST('validate_invoices', 'int');
336
337 $errors = array();
338
339 $TFact = array();
340 $TFactThird = array();
341 $TFactThirdNbLines = array();
342
343 $nb_bills_created = 0;
344 $lastid= 0;
345 $lastref = '';
346
347 $db->begin();
348
349 $nbOrders = is_array($orders) ? count($orders) : 1;
350
351 foreach ($orders as $id_order) {
352 $cmd = new Commande($db);
353 if ($cmd->fetch($id_order) <= 0) {
354 continue;
355 }
356 $cmd->fetch_thirdparty();
357
358 $objecttmp = new Facture($db);
359 if (!empty($createbills_onebythird) && !empty($TFactThird[$cmd->socid])) {
360 // If option "one bill per third" is set, and an invoice for this thirdparty was already created, we re-use it.
361 $objecttmp = $TFactThird[$cmd->socid];
362 } else {
363 // If we want one invoice per order or if there is no first invoice yet for this thirdparty.
364 $objecttmp->socid = $cmd->socid;
365 $objecttmp->thirdparty = $cmd->thirdparty;
366
367 $objecttmp->type = $objecttmp::TYPE_STANDARD;
368 $objecttmp->cond_reglement_id = !empty($cmd->cond_reglement_id) ? $cmd->cond_reglement_id : $cmd->thirdparty->cond_reglement_id;
369 $objecttmp->mode_reglement_id = !empty($cmd->mode_reglement_id) ? $cmd->mode_reglement_id : $cmd->thirdparty->mode_reglement_id;
370
371 $objecttmp->fk_project = $cmd->fk_project;
372 $objecttmp->multicurrency_code = $cmd->multicurrency_code;
373 if (empty($createbills_onebythird)) {
374 $objecttmp->ref_client = $cmd->ref_client;
375 }
376
377 $datefacture = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int'));
378 if (empty($datefacture)) {
379 $datefacture = dol_now();
380 }
381
382 $objecttmp->date = $datefacture;
383 $objecttmp->origin = 'commande';
384 $objecttmp->origin_id = $id_order;
385
386 $objecttmp->array_options = $cmd->array_options; // Copy extrafields
387
388 $res = $objecttmp->create($user);
389
390 if ($res > 0) {
391 $nb_bills_created++;
392 $lastref = $objecttmp->ref;
393 $lastid = $objecttmp->id;
394
395 $TFactThird[$cmd->socid] = $objecttmp;
396 $TFactThirdNbLines[$cmd->socid] = 0; //init nblines to have lines ordered by expedition and rang
397 } else {
398 $langs->load("errors");
399 $errors[] = $cmd->ref.' : '.$langs->trans($objecttmp->errors[0]);
400 $error++;
401 }
402 }
403
404 if ($objecttmp->id > 0) {
405 $res = $objecttmp->add_object_linked($objecttmp->origin, $id_order);
406
407 if ($res == 0) {
408 $errors[] = $cmd->ref.' : '.$langs->trans($objecttmp->errors[0]);
409 $error++;
410 }
411
412 if (!$error) {
413 $lines = $cmd->lines;
414 if (empty($lines) && method_exists($cmd, 'fetch_lines')) {
415 $cmd->fetch_lines();
416 $lines = $cmd->lines;
417 }
418
419 $fk_parent_line = 0;
420 $num = count($lines);
421
422 for ($i = 0; $i < $num; $i++) {
423 $desc = ($lines[$i]->desc ? $lines[$i]->desc : '');
424 // If we build one invoice for several orders, we must put the ref of order on the invoice line
425 if (!empty($createbills_onebythird)) {
426 $desc = dol_concatdesc($desc, $langs->trans("Order").' '.$cmd->ref.' - '.dol_print_date($cmd->date, 'day'));
427 }
428
429 if ($lines[$i]->subprice < 0 && !getDolGlobalString('INVOICE_KEEP_DISCOUNT_LINES_AS_IN_ORIGIN')) {
430 // Negative line, we create a discount line
431 $discount = new DiscountAbsolute($db);
432 $discount->fk_soc = $objecttmp->socid;
433 $discount->amount_ht = abs($lines[$i]->total_ht);
434 $discount->amount_tva = abs($lines[$i]->total_tva);
435 $discount->amount_ttc = abs($lines[$i]->total_ttc);
436 $discount->tva_tx = $lines[$i]->tva_tx;
437 $discount->fk_user = $user->id;
438 $discount->description = $desc;
439 $discountid = $discount->create($user);
440 if ($discountid > 0) {
441 $result = $objecttmp->insert_discount($discountid);
442 //$result=$discount->link_to_invoice($lineid,$id);
443 } else {
444 setEventMessages($discount->error, $discount->errors, 'errors');
445 $error++;
446 break;
447 }
448 } else {
449 // Positive line
450 $product_type = ($lines[$i]->product_type ? $lines[$i]->product_type : 0);
451 // Date start
452 $date_start = false;
453 if ($lines[$i]->date_debut_prevue) {
454 $date_start = $lines[$i]->date_debut_prevue;
455 }
456 if ($lines[$i]->date_debut_reel) {
457 $date_start = $lines[$i]->date_debut_reel;
458 }
459 if ($lines[$i]->date_start) {
460 $date_start = $lines[$i]->date_start;
461 }
462 //Date end
463 $date_end = false;
464 if ($lines[$i]->date_fin_prevue) {
465 $date_end = $lines[$i]->date_fin_prevue;
466 }
467 if ($lines[$i]->date_fin_reel) {
468 $date_end = $lines[$i]->date_fin_reel;
469 }
470 if ($lines[$i]->date_end) {
471 $date_end = $lines[$i]->date_end;
472 }
473 // Reset fk_parent_line for no child products and special product
474 if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9) {
475 $fk_parent_line = 0;
476 }
477
478 // Extrafields
479 if (method_exists($lines[$i], 'fetch_optionals')) {
480 $lines[$i]->fetch_optionals();
481 $array_options = $lines[$i]->array_options;
482 }
483
484 $objecttmp->context['createfromclone'] = 'createfromclone';
485
486 $rang = ($nbOrders > 1) ? -1 : $lines[$i]->rang;
487 //there may already be rows from previous orders
488 if (!empty($createbills_onebythird)) {
489 $TFactThirdNbLines[$cmd->socid]++;
490 $rang = $TFactThirdNbLines[$cmd->socid];
491 }
492
493 $result = $objecttmp->addline(
494 $desc,
495 $lines[$i]->subprice,
496 $lines[$i]->qty,
497 $lines[$i]->tva_tx,
498 $lines[$i]->localtax1_tx,
499 $lines[$i]->localtax2_tx,
500 $lines[$i]->fk_product,
501 $lines[$i]->remise_percent,
502 $date_start,
503 $date_end,
504 0,
505 $lines[$i]->info_bits,
506 $lines[$i]->fk_remise_except,
507 'HT',
508 0,
509 $product_type,
510 $rang,
511 $lines[$i]->special_code,
512 $objecttmp->origin,
513 $lines[$i]->rowid,
514 $fk_parent_line,
515 $lines[$i]->fk_fournprice,
516 $lines[$i]->pa_ht,
517 $lines[$i]->label,
518 $array_options,
519 100,
520 0,
521 $lines[$i]->fk_unit
522 );
523 if ($result > 0) {
524 $lineid = $result;
525 } else {
526 $lineid = 0;
527 $error++;
528 $errors[] = $objecttmp->error;
529 break;
530 }
531 // Defined the new fk_parent_line
532 if ($result > 0 && $lines[$i]->product_type == 9) {
533 $fk_parent_line = $result;
534 }
535 }
536 }
537 }
538 }
539
540 //$cmd->classifyBilled($user); // Disabled. This behavior must be set or not using the workflow module.
541
542 if (!empty($createbills_onebythird) && empty($TFactThird[$cmd->socid])) {
543 $TFactThird[$cmd->socid] = $objecttmp;
544 } else {
545 $TFact[$objecttmp->id] = $objecttmp;
546 }
547 }
548
549 // Build doc with all invoices
550 $TAllFact = empty($createbills_onebythird) ? $TFact : $TFactThird;
551 $toselect = array();
552
553 if (!$error && $validate_invoices) {
554 $massaction = $action = 'builddoc';
555
556 foreach ($TAllFact as &$objecttmp) {
557 $result = $objecttmp->validate($user);
558 if ($result <= 0) {
559 $error++;
560 setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
561 break;
562 }
563
564 $id = $objecttmp->id; // For builddoc action
565
566 // Builddoc
567 $donotredirect = 1;
568 $upload_dir = $conf->facture->dir_output;
569 $permissiontoadd = $user->hasRight('facture', 'creer');
570
571 // Call action to build doc
572 $savobject = $object;
573 $object = $objecttmp;
574 include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
575 $object = $savobject;
576 }
577
578 $massaction = $action = 'confirm_createbills';
579 }
580
581 if (!$error) {
582 $db->commit();
583
584 if ($nb_bills_created == 1) {
585 $texttoshow = $langs->trans('BillXCreated', '{s1}');
586 $texttoshow = str_replace('{s1}', '<a href="'.DOL_URL_ROOT.'/compta/facture/card.php?id='.urlencode($lastid).'">'.$lastref.'</a>', $texttoshow);
587 setEventMessages($texttoshow, null, 'mesgs');
588 } else {
589 setEventMessages($langs->trans('BillCreated', $nb_bills_created), null, 'mesgs');
590 }
591
592 // Make a redirect to avoid to bill twice if we make a refresh or back
593 $param = '';
594 if (!empty($mode)) {
595 $param .= '&mode='.urlencode($mode);
596 }
597 if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
598 $param .= '&contextpage='.urlencode($contextpage);
599 }
600 if ($limit > 0 && $limit != $conf->liste_limit) {
601 $param .= '&limit='.((int) $limit);
602 }
603 if ($optioncss != '') {
604 $param .= '&optioncss='.urlencode($optioncss);
605 }
606 if ($search_all) {
607 $param .= '&search_all='.urlencode($search_all);
608 }
609 if ($show_files) {
610 $param .= '&show_files='.urlencode($show_files);
611 }
612 if ($socid > 0) {
613 $param .= '&socid='.urlencode($socid);
614 }
615 if ($search_status != '') {
616 $param .= '&search_status='.urlencode($search_status);
617 }
618 if ($search_option) {
619 $param .= "&search_option=".urlencode($search_option);
620 }
621 if ($search_orderday) {
622 $param .= '&search_orderday='.urlencode($search_orderday);
623 }
624 if ($search_ordermonth) {
625 $param .= '&search_ordermonth='.urlencode($search_ordermonth);
626 }
627 if ($search_orderyear) {
628 $param .= '&search_orderyear='.urlencode($search_orderyear);
629 }
630 if ($search_deliveryday) {
631 $param .= '&search_deliveryday='.urlencode($search_deliveryday);
632 }
633 if ($search_deliverymonth) {
634 $param .= '&search_deliverymonth='.urlencode($search_deliverymonth);
635 }
636 if ($search_deliveryyear) {
637 $param .= '&search_deliveryyear='.urlencode($search_deliveryyear);
638 }
639 if ($search_ref) {
640 $param .= '&search_ref='.urlencode($search_ref);
641 }
642 if ($search_company) {
643 $param .= '&search_company='.urlencode($search_company);
644 }
645 if ($search_ref_customer) {
646 $param .= '&search_ref_customer='.urlencode($search_ref_customer);
647 }
648 if ($search_user > 0) {
649 $param .= '&search_user='.urlencode($search_user);
650 }
651 if ($search_sale > 0) {
652 $param .= '&search_sale='.urlencode($search_sale);
653 }
654 if ($search_total_ht != '') {
655 $param .= '&search_total_ht='.urlencode($search_total_ht);
656 }
657 if ($search_total_vat != '') {
658 $param .= '&search_total_vat='.urlencode($search_total_vat);
659 }
660 if ($search_total_ttc != '') {
661 $param .= '&search_total_ttc='.urlencode($search_total_ttc);
662 }
663 if ($search_project_ref >= 0) {
664 $param .= "&search_project_ref=".urlencode($search_project_ref);
665 }
666 if ($search_billed != '') {
667 $param .= '&search_billed='.urlencode($search_billed);
668 }
669
670 header("Location: ".$_SERVER['PHP_SELF'].'?'.$param);
671 exit;
672 } else {
673 $db->rollback();
674
675 $action = 'create';
676 $_GET["origin"] = $_POST["origin"];
677 $_GET["originid"] = $_POST["originid"];
678 if (!empty($errors)) {
679 setEventMessages(null, $errors, 'errors');
680 } else {
681 setEventMessages("Error", null, 'errors');
682 }
683 $error++;
684 }
685 }
686}
687if ($action == 'validate' && $permissiontoadd) {
688 if (GETPOST('confirm') == 'yes') {
689 $objecttmp = new $objectclass($db);
690 $db->begin();
691 $error = 0;
692 foreach ($toselect as $checked) {
693 if ($objecttmp->fetch($checked)) {
694 if ($objecttmp->statut == 0) {
695 if (!empty($objecttmp->fk_warehouse)) {
696 $idwarehouse = $objecttmp->fk_warehouse;
697 } else {
698 $idwarehouse = 0;
699 }
700 if ($objecttmp->valid($user, $idwarehouse)) {
701 setEventMessages($langs->trans('hasBeenValidated', $objecttmp->ref), null, 'mesgs');
702 } else {
703 setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
704 $error++;
705 }
706 } else {
707 $langs->load("errors");
708 setEventMessages($langs->trans('ErrorIsNotADraft', $objecttmp->ref), null, 'errors');
709 $error++;
710 }
711 } else {
712 dol_print_error($db);
713 $error++;
714 }
715 }
716 if ($error) {
717 $db->rollback();
718 } else {
719 $db->commit();
720 }
721 }
722}
723if ($action == 'shipped' && $permissiontoadd) {
724 if (GETPOST('confirm') == 'yes') {
725 $objecttmp = new $objectclass($db);
726 $db->begin();
727 $error = 0;
728 foreach ($toselect as $checked) {
729 if ($objecttmp->fetch($checked)) {
730 if ($objecttmp->statut == 1 || $objecttmp->statut == 2) {
731 if ($objecttmp->cloture($user)) {
732 setEventMessages($langs->trans('StatusOrderDelivered', $objecttmp->ref), null, 'mesgs');
733 } else {
734 setEventMessages($langs->trans('ErrorOrderStatusCantBeSetToDelivered'), null, 'errors');
735 $error++;
736 }
737 } else {
738 $langs->load("errors");
739 setEventMessages($langs->trans('ErrorIsNotADraft', $objecttmp->ref), null, 'errors');
740 $error++;
741 }
742 } else {
743 dol_print_error($db);
744 $error++;
745 }
746 }
747 if ($error) {
748 $db->rollback();
749 } else {
750 $db->commit();
751 }
752 }
753}
754
755// Closed records
756if (!$error && $massaction === 'setbilled' && $permissiontoclose) {
757 $db->begin();
758
759 $objecttmp = new $objectclass($db);
760 $nbok = 0;
761 foreach ($toselect as $toselectid) {
762 $result = $objecttmp->fetch($toselectid);
763 if ($result > 0) {
764 $result = $objecttmp->classifyBilled($user, 0);
765 if ($result <= 0) {
766 setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
767 $error++;
768 break;
769 } else {
770 $nbok++;
771 }
772 } else {
773 setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
774 $error++;
775 break;
776 }
777 }
778
779 if (!$error) {
780 if ($nbok > 1) {
781 setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs');
782 } else {
783 setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs');
784 }
785 $db->commit();
786 } else {
787 $db->rollback();
788 }
789}
790
791
792/*
793 * View
794 */
795
796$form = new Form($db);
797$formother = new FormOther($db);
798$formfile = new FormFile($db);
799$formmargin = null;
800if (isModEnabled('margin')) {
801 $formmargin = new FormMargin($db);
802}
803$companystatic = new Societe($db);
804$company_url_list = array();
805$formcompany = new FormCompany($db);
806$projectstatic = new Project($db);
807
808$now = dol_now();
809
810$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
811$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
812
813$title = $langs->trans("Orders");
814$help_url = "EN:Module_Customers_Orders|FR:Module_Commandes_Clients|ES:Módulo_Pedidos_de_clientes";
815
816// Build and execute select
817// --------------------------------------------------------------------
818$sql = 'SELECT';
819if ($search_all || $search_user > 0) {
820 $sql = 'SELECT DISTINCT';
821}
822$sql .= ' s.rowid as socid, s.nom as name, s.name_alias as alias, s.email, s.phone, s.fax, s.address, s.town, s.zip, s.fk_pays, s.client, s.fournisseur, s.code_client,';
823$sql .= " s.parent as fk_parent,";
824$sql .= " s2.nom as name2,";
825$sql .= " typent.code as typent_code,";
826$sql .= " state.code_departement as state_code, state.nom as state_name,";
827$sql .= " country.code as country_code,";
828$sql .= ' c.rowid, c.ref, c.total_ht, c.total_tva, c.total_ttc, c.ref_client, c.fk_user_author,';
829$sql .= ' c.fk_multicurrency, c.multicurrency_code, c.multicurrency_tx, c.multicurrency_total_ht, c.multicurrency_total_tva as multicurrency_total_vat, c.multicurrency_total_ttc,';
830$sql .= ' c.date_valid, c.date_commande, c.note_public, c.note_private, c.date_livraison as date_delivery, c.fk_statut, c.facture as billed,';
831$sql .= ' c.date_creation as date_creation, c.tms as date_update, c.date_cloture as date_cloture,';
832$sql .= ' p.rowid as project_id, p.ref as project_ref, p.title as project_label,';
833$sql .= ' u.login, u.lastname, u.firstname, u.email as user_email, u.statut as user_statut, u.entity, u.photo, u.office_phone, u.office_fax, u.user_mobile, u.job, u.gender,';
834$sql .= ' c.fk_cond_reglement,c.deposit_percent,c.fk_mode_reglement,c.fk_shipping_method,';
835$sql .= ' c.fk_input_reason, c.import_key';
836
837// Add fields from extrafields
838if (!empty($extrafields->attributes[$object->table_element]['label'])) {
839 foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
840 $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : '');
841 }
842}
843
844// Add fields from hooks
845$parameters = array();
846$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
847$sql .= $hookmanager->resPrint;
848$sql = preg_replace('/,\s*$/', '', $sql);
849
850$sqlfields = $sql; // $sql fields to remove for count total
851
852$sql .= ' FROM '.MAIN_DB_PREFIX.'societe as s';
853$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s2 ON s2.rowid = s.parent";
854$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays)";
855$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typent)";
856$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)";
857$sql .= ', '.MAIN_DB_PREFIX.'commande as c';
858if (!empty($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
859 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."commande_extrafields as ef on (c.rowid = ef.fk_object)";
860}
861if ($search_all) {
862 $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'commandedet as pd ON c.rowid=pd.fk_commande';
863}
864$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = c.fk_projet";
865$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'user as u ON c.fk_user_author = u.rowid';
866if ($search_user > 0) {
867 $sql .= ", ".MAIN_DB_PREFIX."element_contact as ec";
868 $sql .= ", ".MAIN_DB_PREFIX."c_type_contact as tc";
869}
870
871// Add table from hooks
872$parameters = array();
873$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
874$sql .= $hookmanager->resPrint;
875
876$sql .= ' WHERE c.fk_soc = s.rowid';
877$sql .= ' AND c.entity IN ('.getEntity('commande').')';
878if ($socid > 0) {
879 $sql .= ' AND s.rowid = '.((int) $socid);
880}
881if ($search_ref) {
882 $sql .= natural_search('c.ref', $search_ref);
883}
884if ($search_ref_customer) {
885 $sql .= natural_search('c.ref_client', $search_ref_customer);
886}
887if ($search_all) {
888 $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
889}
890if ($search_billed != '' && $search_billed >= 0) {
891 $sql .= ' AND c.facture = '.((int) $search_billed);
892}
893if ($search_status != '') {
894 if ($search_status <= 3 && $search_status >= -1) { // status from -1 to 3 are real status (other are virtual combination)
895 if ($search_status == 1 && !isModEnabled('expedition')) {
896 $sql .= ' AND c.fk_statut IN (1,2)'; // If module expedition disabled, we include order with status 'sending in process' into 'validated'
897 } else {
898 $sql .= ' AND c.fk_statut = '.((int) $search_status); // draft, validated, in process or canceled
899 }
900 }
901 if ($search_status == -2) { // "validated + in progress"
902 //$sql.= ' AND c.fk_statut IN (1,2,3) AND c.facture = 0';
903 $sql .= " AND (c.fk_statut IN (1,2))";
904 }
905 if ($search_status == -3) { // "validated + in progress + shipped"
906 //$sql.= ' AND c.fk_statut in (1,2,3)';
907 //$sql.= ' AND c.facture = 0'; // invoice not created
908 $sql .= ' AND (c.fk_statut IN (1,2,3))'; // validated, in process or closed
909 }
910}
911if ($search_option == 'late') {
912 $sql .= " AND c.date_commande < '".$db->idate(dol_now() - $conf->commande->client->warning_delay)."'";
913}
914if ($search_datecloture_start) {
915 $sql .= " AND c.date_cloture >= '".$db->idate($search_datecloture_start)."'";
916}
917if ($search_datecloture_end) {
918 $sql .= " AND c.date_cloture <= '".$db->idate($search_datecloture_end)."'";
919}
920if ($search_dateorder_start) {
921 $sql .= " AND c.date_commande >= '".$db->idate($search_dateorder_start)."'";
922}
923if ($search_dateorder_end) {
924 $sql .= " AND c.date_commande <= '".$db->idate($search_dateorder_end)."'";
925}
926if ($search_datedelivery_start) {
927 $sql .= " AND c.date_livraison >= '".$db->idate($search_datedelivery_start)."'";
928}
929if ($search_datedelivery_end) {
930 $sql .= " AND c.date_livraison <= '".$db->idate($search_datedelivery_end)."'";
931}
932if ($search_town) {
933 $sql .= natural_search('s.town', $search_town);
934}
935if ($search_zip) {
936 $sql .= natural_search("s.zip", $search_zip);
937}
938if ($search_state) {
939 $sql .= natural_search("state.nom", $search_state);
940}
941if ($search_country) {
942 $sql .= " AND s.fk_pays IN (".$db->sanitize($search_country).')';
943}
944if ($search_type_thirdparty && $search_type_thirdparty != '-1') {
945 $sql .= " AND s.fk_typent IN (".$db->sanitize($search_type_thirdparty).')';
946}
947if (empty($arrayfields['s.name_alias']['checked']) && $search_company) {
948 $sql .= natural_search(array("s.nom", "s.name_alias"), $search_company);
949} else {
950 if ($search_company) {
951 $sql .= natural_search('s.nom', $search_company);
952 }
953 if ($search_company_alias) {
954 $sql .= natural_search('s.name_alias', $search_company_alias);
955 }
956}
957if ($search_parent_name) {
958 $sql .= natural_search('s2.nom', $search_parent_name);
959}
960if ($search_user > 0) {
961 $sql .= " AND ec.fk_c_type_contact = tc.rowid AND tc.element='commande' AND tc.source='internal' AND ec.element_id = c.rowid AND ec.fk_socpeople = ".((int) $search_user);
962}
963if ($search_total_ht != '') {
964 $sql .= natural_search('c.total_ht', $search_total_ht, 1);
965}
966if ($search_total_vat != '') {
967 $sql .= natural_search('c.total_tva', $search_total_vat, 1);
968}
969if ($search_total_ttc != '') {
970 $sql .= natural_search('c.total_ttc', $search_total_ttc, 1);
971}
972if ($search_warehouse != '' && $search_warehouse > 0) {
973 $sql .= natural_search('c.fk_warehouse', $search_warehouse, 1);
974}
975if ($search_multicurrency_code != '') {
976 $sql .= " AND c.multicurrency_code = '".$db->escape($search_multicurrency_code)."'";
977}
978if ($search_multicurrency_tx != '') {
979 $sql .= natural_search('c.multicurrency_tx', $search_multicurrency_tx, 1);
980}
981if ($search_multicurrency_montant_ht != '') {
982 $sql .= natural_search('c.multicurrency_total_ht', $search_multicurrency_montant_ht, 1);
983}
984if ($search_multicurrency_montant_vat != '') {
985 $sql .= natural_search('c.multicurrency_total_tva', $search_multicurrency_montant_vat, 1);
986}
987if ($search_multicurrency_montant_ttc != '') {
988 $sql .= natural_search('c.multicurrency_total_ttc', $search_multicurrency_montant_ttc, 1);
989}
990if ($search_login) {
991 $sql .= natural_search(array("u.login", "u.firstname", "u.lastname"), $search_login);
992}
993if ($search_project_ref != '') {
994 $sql .= natural_search("p.ref", $search_project_ref);
995}
996if ($search_project != '') {
997 $sql .= natural_search("p.title", $search_project);
998}
999if ($search_fk_cond_reglement > 0) {
1000 $sql .= " AND c.fk_cond_reglement = ".((int) $search_fk_cond_reglement);
1001}
1002if ($search_fk_shipping_method > 0) {
1003 $sql .= " AND c.fk_shipping_method = ".((int) $search_fk_shipping_method);
1004}
1005if ($search_fk_mode_reglement > 0) {
1006 $sql .= " AND c.fk_mode_reglement = ".((int) $search_fk_mode_reglement);
1007}
1008if ($search_fk_input_reason > 0) {
1009 $sql .= " AND c.fk_input_reason = ".((int) $search_fk_input_reason);
1010}
1011// Search on sale representative
1012if ($search_sale && $search_sale != '-1') {
1013 if ($search_sale == -2) {
1014 $sql .= " AND NOT EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc WHERE sc.fk_soc = c.fk_soc)";
1015 } elseif ($search_sale > 0) {
1016 $sql .= " AND EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc WHERE sc.fk_soc = c.fk_soc AND sc.fk_user = ".((int) $search_sale).")";
1017 }
1018}
1019// Search for tag/category ($searchCategoryCustomerList is an array of ID)
1020$searchCategoryCustomerOperator = -1;
1021$searchCategoryCustomerList = array($search_categ_cus);
1022if (!empty($searchCategoryCustomerList)) {
1023 $searchCategoryCustomerSqlList = array();
1024 $listofcategoryid = '';
1025 foreach ($searchCategoryCustomerList as $searchCategoryCustomer) {
1026 if (intval($searchCategoryCustomer) == -2) {
1027 $searchCategoryCustomerSqlList[] = "NOT EXISTS (SELECT cs.fk_soc FROM ".MAIN_DB_PREFIX."categorie_societe as cs WHERE s.rowid = cs.fk_soc)";
1028 } elseif (intval($searchCategoryCustomer) > 0) {
1029 if ($searchCategoryCustomerOperator == 0) {
1030 $searchCategoryCustomerSqlList[] = " EXISTS (SELECT cs.fk_soc FROM ".MAIN_DB_PREFIX."categorie_societe as cs WHERE s.rowid = cs.fk_soc AND cs.fk_categorie = ".((int) $searchCategoryCustomer).")";
1031 } else {
1032 $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryCustomer);
1033 }
1034 }
1035 }
1036 if ($listofcategoryid) {
1037 $searchCategoryCustomerSqlList[] = " EXISTS (SELECT cs.fk_soc FROM ".MAIN_DB_PREFIX."categorie_societe as cs WHERE s.rowid = cs.fk_soc AND cs.fk_categorie IN (".$db->sanitize($listofcategoryid)."))";
1038 }
1039 if ($searchCategoryCustomerOperator == 1) {
1040 if (!empty($searchCategoryCustomerSqlList)) {
1041 $sql .= " AND (".implode(' OR ', $searchCategoryCustomerSqlList).")";
1042 }
1043 } else {
1044 if (!empty($searchCategoryCustomerSqlList)) {
1045 $sql .= " AND (".implode(' AND ', $searchCategoryCustomerSqlList).")";
1046 }
1047 }
1048}
1049// Search for tag/category ($searchCategoryProductList is an array of ID)
1050$searchCategoryProductOperator = -1;
1051$searchCategoryProductList = array($search_product_category);
1052if (!empty($searchCategoryProductList)) {
1053 $searchCategoryProductSqlList = array();
1054 $listofcategoryid = '';
1055 foreach ($searchCategoryProductList as $searchCategoryProduct) {
1056 if (intval($searchCategoryProduct) == -2) {
1057 $searchCategoryProductSqlList[] = "NOT EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX."categorie_product as ck, ".MAIN_DB_PREFIX."commandedet as cd WHERE cd.fk_commande = c.rowid AND cd.fk_product = ck.fk_product)";
1058 } elseif (intval($searchCategoryProduct) > 0) {
1059 if ($searchCategoryProductOperator == 0) {
1060 $searchCategoryProductSqlList[] = " EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX."categorie_product as ck, ".MAIN_DB_PREFIX."commandedet as cd WHERE cd.fk_commande = c.rowid AND cd.fk_product = ck.fk_product AND ck.fk_categorie = ".((int) $searchCategoryProduct).")";
1061 } else {
1062 $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryProduct);
1063 }
1064 }
1065 }
1066 if ($listofcategoryid) {
1067 $searchCategoryProductSqlList[] = " EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX."categorie_product as ck, ".MAIN_DB_PREFIX."commandedet as cd WHERE cd.fk_commande = c.rowid AND cd.fk_product = ck.fk_product AND ck.fk_categorie IN (".$db->sanitize($listofcategoryid)."))";
1068 }
1069 if ($searchCategoryProductOperator == 1) {
1070 if (!empty($searchCategoryProductSqlList)) {
1071 $sql .= " AND (".implode(' OR ', $searchCategoryProductSqlList).")";
1072 }
1073 } else {
1074 if (!empty($searchCategoryProductSqlList)) {
1075 $sql .= " AND (".implode(' AND ', $searchCategoryProductSqlList).")";
1076 }
1077 }
1078}
1079// Add where from extra fields
1080include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
1081// Add where from hooks
1082$parameters = array();
1083$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1084$sql .= $hookmanager->resPrint;
1085
1086// Add HAVING from hooks
1087$parameters = array();
1088$reshook = $hookmanager->executeHooks('printFieldListHaving', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1089$sql .= empty($hookmanager->resPrint) ? "" : " HAVING 1=1 ".$hookmanager->resPrint;
1090//print $sql;
1091
1092// Count total nb of records
1093$nbtotalofrecords = '';
1094if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
1095 /* The fast and low memory method to get and count full list converts the sql into a sql count */
1096 $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql);
1097 $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount);
1098 $resql = $db->query($sqlforcount);
1099 if ($resql) {
1100 $objforcount = $db->fetch_object($resql);
1101 $nbtotalofrecords = $objforcount->nbtotalofrecords;
1102 } else {
1103 dol_print_error($db);
1104 }
1105
1106 if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller than paging size (filtering), goto and load page 0
1107 $page = 0;
1108 $offset = 0;
1109 }
1110 $db->free($resql);
1111}
1112
1113$sql .= $db->order($sortfield, $sortorder);
1114if ($limit) {
1115 $sql .= $db->plimit($limit + 1, $offset);
1116}
1117//print $sql;
1118
1119$resql = $db->query($sql);
1120if (!$resql) {
1121 dol_print_error($db);
1122 exit;
1123}
1124
1125if ($socid > 0) {
1126 $soc = new Societe($db);
1127 $soc->fetch($socid);
1128 $title = $langs->trans('CustomersOrders').' - '.$soc->name;
1129 if (empty($search_company)) {
1130 $search_company = $soc->name;
1131 }
1132} else {
1133 $title = $langs->trans('CustomersOrders');
1134}
1135if (strval($search_status) == '0') {
1136 $title .= ' - '.$langs->trans('StatusOrderDraftShort');
1137}
1138if ($search_status == 1) {
1139 $title .= ' - '.$langs->trans('StatusOrderValidatedShort');
1140}
1141if ($search_status == 2) {
1142 $title .= ' - '.$langs->trans('StatusOrderSentShort');
1143}
1144if ($search_status == 3) {
1145 $title .= ' - '.$langs->trans('StatusOrderToBillShort');
1146}
1147if ($search_status == -1) {
1148 $title .= ' - '.$langs->trans('StatusOrderCanceledShort');
1149}
1150if ($search_status == -2) {
1151 $title .= ' - '.$langs->trans('StatusOrderToProcessShort');
1152}
1153if ($search_status == -3) {
1154 $title .= ' - '.$langs->trans('StatusOrderValidated').', '.(!isModEnabled('expedition') ? '' : $langs->trans("StatusOrderSent").', ').$langs->trans('StatusOrderToBill');
1155}
1156if ($search_status == -4) {
1157 $title .= ' - '.$langs->trans("StatusOrderValidatedShort").'+'.$langs->trans("StatusOrderSentShort");
1158}
1159
1160$num = $db->num_rows($resql);
1161
1162$arrayofselected = is_array($toselect) ? $toselect : array();
1163
1164if ($num == 1 && getDolGlobalString('MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all) {
1165 $obj = $db->fetch_object($resql);
1166 $id = $obj->rowid;
1167 header("Location: ".DOL_URL_ROOT.'/commande/card.php?id='.$id);
1168 exit;
1169}
1170
1171// Output page
1172// --------------------------------------------------------------------
1173
1174llxHeader('', $title, $help_url);
1175
1176$arrayofselected = is_array($toselect) ? $toselect : array();
1177
1178$param = '';
1179if (!empty($mode)) {
1180 $param .= '&mode='.urlencode($mode);
1181}
1182if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
1183 $param .= '&contextpage='.urlencode($contextpage);
1184}
1185if ($limit > 0 && $limit != $conf->liste_limit) {
1186 $param .= '&limit='.((int) $limit);
1187}
1188if ($search_all) {
1189 $param .= '&search_all='.urlencode($search_all);
1190}
1191if ($socid > 0) {
1192 $param .= '&socid='.((int) $socid);
1193}
1194if ($search_status != '') {
1195 $param .= '&search_status='.urlencode($search_status);
1196}
1197if ($search_option) {
1198 $param .= "&search_option=".urlencode($search_option);
1199}
1200if ($search_datecloture_start) {
1201 $param .= '&search_datecloture_startday='.dol_print_date($search_datecloture_start, '%d').'&search_datecloture_startmonth='.dol_print_date($search_datecloture_start, '%m').'&search_datecloture_startyear='.dol_print_date($search_datecloture_start, '%Y');
1202}
1203if ($search_datecloture_end) {
1204 $param .= '&search_datecloture_endday='.dol_print_date($search_datecloture_end, '%d').'&search_datecloture_endmonth='.dol_print_date($search_datecloture_end, '%m').'&search_datecloture_endyear='.dol_print_date($search_datecloture_end, '%Y');
1205}
1206if ($search_dateorder_start) {
1207 $param .= '&search_dateorder_start_day='.dol_print_date($search_dateorder_start, '%d').'&search_dateorder_start_month='.dol_print_date($search_dateorder_start, '%m').'&search_dateorder_start_year='.dol_print_date($search_dateorder_start, '%Y');
1208}
1209if ($search_dateorder_end) {
1210 $param .= '&search_dateorder_end_day='.dol_print_date($search_dateorder_end, '%d').'&search_dateorder_end_month='.dol_print_date($search_dateorder_end, '%m').'&search_dateorder_end_year='.dol_print_date($search_dateorder_end, '%Y');
1211}
1212if ($search_datedelivery_start) {
1213 $param .= '&search_datedelivery_start_day='.dol_print_date($search_datedelivery_start, '%d').'&search_datedelivery_start_month='.dol_print_date($search_datedelivery_start, '%m').'&search_datedelivery_start_year='.dol_print_date($search_datedelivery_start, '%Y');
1214}
1215if ($search_datedelivery_end) {
1216 $param .= '&search_datedelivery_end_day='.dol_print_date($search_datedelivery_end, '%d').'&search_datedelivery_end_month='.dol_print_date($search_datedelivery_end, '%m').'&search_datedelivery_end_year='.dol_print_date($search_datedelivery_end, '%Y');
1217}
1218if ($search_ref) {
1219 $param .= '&search_ref='.urlencode($search_ref);
1220}
1221if ($search_company) {
1222 $param .= '&search_company='.urlencode($search_company);
1223}
1224if ($search_company_alias) {
1225 $param .= '&search_company_alias='.urlencode($search_company_alias);
1226}
1227if ($search_parent_name != '') {
1228 $param .= '&search_parent_name='.urlencode($search_parent_name);
1229}
1230if ($search_ref_customer) {
1231 $param .= '&search_ref_customer='.urlencode($search_ref_customer);
1232}
1233if ($search_user > 0) {
1234 $param .= '&search_user='.urlencode($search_user);
1235}
1236if ($search_sale > 0) {
1237 $param .= '&search_sale='.urlencode($search_sale);
1238}
1239if ($search_total_ht != '') {
1240 $param .= '&search_total_ht='.urlencode($search_total_ht);
1241}
1242if ($search_total_vat != '') {
1243 $param .= '&search_total_vat='.urlencode($search_total_vat);
1244}
1245if ($search_total_ttc != '') {
1246 $param .= '&search_total_ttc='.urlencode($search_total_ttc);
1247}
1248if ($search_warehouse != '') {
1249 $param .= '&search_warehouse='.urlencode($search_warehouse);
1250}
1251if ($search_login) {
1252 $param .= '&search_login='.urlencode($search_login);
1253}
1254if ($search_multicurrency_code != '') {
1255 $param .= '&search_multicurrency_code='.urlencode($search_multicurrency_code);
1256}
1257if ($search_multicurrency_tx != '') {
1258 $param .= '&search_multicurrency_tx='.urlencode($search_multicurrency_tx);
1259}
1260if ($search_multicurrency_montant_ht != '') {
1261 $param .= '&search_multicurrency_montant_ht='.urlencode($search_multicurrency_montant_ht);
1262}
1263if ($search_multicurrency_montant_vat != '') {
1264 $param .= '&search_multicurrency_montant_vat='.urlencode($search_multicurrency_montant_vat);
1265}
1266if ($search_multicurrency_montant_ttc != '') {
1267 $param .= '&search_multicurrency_montant_ttc='.urlencode($search_multicurrency_montant_ttc);
1268}
1269if ($search_project_ref >= 0) {
1270 $param .= "&search_project_ref=".urlencode($search_project_ref);
1271}
1272if ($search_town != '') {
1273 $param .= '&search_town='.urlencode($search_town);
1274}
1275if ($search_zip != '') {
1276 $param .= '&search_zip='.urlencode($search_zip);
1277}
1278if ($search_state != '') {
1279 $param .= '&search_state='.urlencode($search_state);
1280}
1281if ($search_country != '') {
1282 $param .= '&search_country='.urlencode($search_country);
1283}
1284if ($search_type_thirdparty && $search_type_thirdparty != '-1') {
1285 $param .= '&search_type_thirdparty='.urlencode($search_type_thirdparty);
1286}
1287if ($search_product_category != '') {
1288 $param .= '&search_product_category='.urlencode($search_product_category);
1289}
1290if (($search_categ_cus > 0) || ($search_categ_cus == -2)) {
1291 $param .= '&search_categ_cus='.urlencode($search_categ_cus);
1292}
1293if ($show_files) {
1294 $param .= '&show_files='.urlencode($show_files);
1295}
1296if ($optioncss != '') {
1297 $param .= '&optioncss='.urlencode($optioncss);
1298}
1299if ($search_billed != '') {
1300 $param .= '&search_billed='.urlencode($search_billed);
1301}
1302if ($search_fk_cond_reglement > 0) {
1303 $param .= '&search_fk_cond_reglement='.urlencode($search_fk_cond_reglement);
1304}
1305if ($search_fk_shipping_method > 0) {
1306 $param .= '&search_fk_shipping_method='.urlencode($search_fk_shipping_method);
1307}
1308if ($search_fk_mode_reglement > 0) {
1309 $param .= '&search_fk_mode_reglement='.urlencode($search_fk_mode_reglement);
1310}
1311if ($search_fk_input_reason > 0) {
1312 $param .= '&search_fk_input_reason='.urlencode($search_fk_input_reason);
1313}
1314
1315// Add $param from extra fields
1316include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
1317
1318// Add $param from hooks
1319$parameters = array();
1320$reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1321$param .= $hookmanager->resPrint;
1322
1323// List of mass actions available
1324$arrayofmassactions = array(
1325 'generate_doc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("ReGeneratePDF"),
1326 'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
1327);
1328if ($permissiontovalidate) {
1329 $arrayofmassactions['prevalidate'] = img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("Validate");
1330}
1331if ($permissiontoclose) {
1332 $arrayofmassactions['preshipped'] = img_picto('', 'dollyrevert', 'class="pictofixedwidth"').$langs->trans("ClassifyShipped");
1333}
1334if (isModEnabled('facture') && $user->hasRight("facture", "creer")) {
1335 $arrayofmassactions['createbills'] = img_picto('', 'bill', 'class="pictofixedwidth"').$langs->trans("CreateInvoiceForThisCustomer");
1336}
1337if ($permissiontoclose) {
1338 $arrayofmassactions['setbilled'] = img_picto('', 'bill', 'class="pictofixedwidth"').$langs->trans("ClassifyBilled");
1339}
1340if ($permissiontocancel) {
1341 $arrayofmassactions['cancelorders'] = img_picto('', 'close_title', 'class="pictofixedwidth"').$langs->trans("CancelOrder");
1342}
1343if (!empty($permissiontodelete)) {
1344 $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
1345}
1346if ($permissiontosendbymail) {
1347 $arrayofmassactions['presend'] = img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail");
1348}
1349if (in_array($massaction, array('presend', 'predelete', 'createbills'))) {
1350 $arrayofmassactions = array();
1351}
1352$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
1353
1354$url = DOL_URL_ROOT.'/commande/card.php?action=create';
1355if (!empty($socid)) {
1356 $url .= '&socid='.$socid;
1357}
1358$newcardbutton = '';
1359$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'));
1360$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'));
1361$newcardbutton .= dolGetButtonTitleSeparator();
1362$newcardbutton .= dolGetButtonTitle($langs->trans('NewOrder'), '', 'fa fa-plus-circle', $url, '', ($contextpage == 'orderlist' || $contextpage == 'billableorders') && $permissiontoadd);
1363
1364// Lines of title fields
1365print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n";
1366if ($optioncss != '') {
1367 print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
1368}
1369print '<input type="hidden" name="token" value="'.newToken().'">';
1370print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
1371print '<input type="hidden" name="action" value="list">';
1372print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
1373print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
1374print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
1375print '<input type="hidden" name="search_status" value="'.$search_status.'">';
1376print '<input type="hidden" name="socid" value="'.$socid.'">';
1377print '<input type="hidden" name="page_y" value="">';
1378print '<input type="hidden" name="mode" value="'.$mode.'">';
1379
1380
1381print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'order', 0, $newcardbutton, '', $limit, 0, 0, 1);
1382
1383$topicmail = "SendOrderRef";
1384$modelmail = "order_send";
1385$objecttmp = new Commande($db);
1386$trackid = 'ord'.$object->id;
1387include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
1388
1389if ($massaction == 'prevalidate') {
1390 print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmMassValidation"), $langs->trans("ConfirmMassValidationQuestion"), "validate", null, '', 0, 200, 500, 1);
1391}
1392if ($massaction == 'preshipped') {
1393 print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("CloseOrder"), $langs->trans("ConfirmCloseOrder"), "shipped", null, '', 0, 200, 500, 1);
1394}
1395
1396if ($massaction == 'createbills') {
1397 print '<input type="hidden" name="massaction" value="confirm_createbills">';
1398
1399 print '<table class="noborder centpercent">';
1400 print '<tr>';
1401 print '<td>';
1402 print $langs->trans('DateInvoice');
1403 print '</td>';
1404 print '<td>';
1405 print $form->selectDate('', '', '', '', '', '', 1, 1);
1406 print '</td>';
1407 print '</tr>';
1408 print '<tr>';
1409 print '<td>';
1410 print $langs->trans('CreateOneBillByThird');
1411 print '</td>';
1412 print '<td>';
1413 print $form->selectyesno('createbills_onebythird', '', 1);
1414 print '</td>';
1415 print '</tr>';
1416 print '<tr>';
1417 print '<td>';
1418 print $langs->trans('ValidateInvoices');
1419 print '</td>';
1420 print '<td>';
1421 if (isModEnabled('stock') && getDolGlobalString('STOCK_CALCULATE_ON_BILL')) {
1422 print $form->selectyesno('validate_invoices', 0, 1, 1);
1423 $langs->load("errors");
1424 print ' ('.$langs->trans("WarningAutoValNotPossibleWhenStockIsDecreasedOnInvoiceVal").')';
1425 } else {
1426 print $form->selectyesno('validate_invoices', 0, 1);
1427 }
1428 if (!empty($conf->workflow->enabled) && getDolGlobalString('WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_ORDER')) {
1429 print ' &nbsp; &nbsp; <span class="opacitymedium">'.$langs->trans("IfValidateInvoiceIsNoOrderStayUnbilled").'</span>';
1430 } else {
1431 print ' &nbsp; &nbsp; <span class="opacitymedium">'.$langs->trans("OptionToSetOrderBilledNotEnabled").'</span>';
1432 }
1433 print '</td>';
1434 print '</tr>';
1435 print '</table>';
1436
1437 print '<div class="center">';
1438 print '<input type="submit" class="button" id="createbills" name="createbills" value="'.$langs->trans('CreateInvoiceForThisCustomer').'"> ';
1439 print '<input type="submit" class="button button-cancel" id="cancel" name="cancel" value="'.$langs->trans("Cancel").'">';
1440 print '</div>';
1441 print '<br><br>';
1442}
1443
1444if ($search_all) {
1445 $setupstring = '';
1446 foreach ($fieldstosearchall as $key => $val) {
1447 $fieldstosearchall[$key] = $langs->trans($val);
1448 $setupstring .= $key."=".$val.";";
1449 }
1450 print '<!-- Search done like if MYOBJECT_QUICKSEARCH_ON_FIELDS = '.$setupstring.' -->'."\n";
1451 print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'</div>';
1452}
1453
1454$moreforfilter = '';
1455
1456// If the user can view prospects? sales other than his own
1457if ($user->hasRight("user", "user", "lire")) {
1458 $langs->load("commercial");
1459 $moreforfilter .= '<div class="divsearchfield">';
1460 $tmptitle = $langs->trans('ThirdPartiesOfSaleRepresentative');
1461 $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, $tmptitle, 'maxwidth250 widthcentpercentminusx');
1462 $moreforfilter .= '</div>';
1463}
1464// If the user can view other users
1465if ($user->hasRight("user", "user", "lire")) {
1466 $moreforfilter .= '<div class="divsearchfield">';
1467 $tmptitle = $langs->trans('LinkedToSpecificUsers');
1468 $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$form->select_dolusers($search_user, 'search_user', $tmptitle, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth250 widthcentpercentminusx');
1469 $moreforfilter .= '</div>';
1470}
1471
1472// If the user can view other products/services than his own
1473if (isModEnabled('categorie') && $user->hasRight("categorie", "lire") && ($user->hasRight("produit", "lire") || $user->hasRight("service", "lire"))) {
1474 include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
1475 $moreforfilter .= '<div class="divsearchfield">';
1476 $tmptitle = $langs->trans('IncludingProductWithTag');
1477 $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, null, 'parent', null, null, 1);
1478 $moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"').$form->selectarray('search_product_category', $cate_arbo, $search_product_category, $tmptitle, 0, 0, '', 0, 0, 0, 0, 'maxwidth300 widthcentpercentminusx', 1);
1479 $moreforfilter .= '</div>';
1480}
1481// If Categories are enabled & user has rights to see
1482if (isModEnabled('categorie') && $user->hasRight("categorie", "lire")) {
1483 require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
1484 $moreforfilter .= '<div class="divsearchfield">';
1485 $tmptitle = $langs->trans('CustomersProspectsCategoriesShort');
1486 $moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"').$formother->select_categories('customer', $search_categ_cus, 'search_categ_cus', 1, $tmptitle, 'maxwidth300 widthcentpercentminusx');
1487 $moreforfilter .= '</div>';
1488}
1489// If Stock is enabled
1490if (isModEnabled('stock') && getDolGlobalString('WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER')) {
1491 require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
1492 $formproduct = new FormProduct($db);
1493 $moreforfilter .= '<div class="divsearchfield">';
1494 $tmptitle = $langs->trans('Warehouse');
1495 $moreforfilter .= img_picto($tmptitle, 'stock', 'class="pictofixedwidth"').$formproduct->selectWarehouses($search_warehouse, 'search_warehouse', '', 1, 0, 0, $tmptitle, 0, 0, array(), 'maxwidth250 widthcentpercentminusx');
1496 $moreforfilter .= '</div>';
1497}
1498
1499$parameters = array();
1500$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1501if (empty($reshook)) {
1502 $moreforfilter .= $hookmanager->resPrint;
1503} else {
1504 $moreforfilter = $hookmanager->resPrint;
1505}
1506
1507if (!empty($moreforfilter)) {
1508 print '<div class="liste_titre liste_titre_bydiv centpercent">';
1509 print $moreforfilter;
1510 print '</div>';
1511}
1512
1513$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
1514$selectedfields = ($mode != 'kanban' ? $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN', '')) : ''); // This also change content of $arrayfields
1515$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
1516
1517if (GETPOST('autoselectall', 'int')) {
1518 $selectedfields .= '<script>';
1519 $selectedfields .= ' $(document).ready(function() {';
1520 $selectedfields .= ' console.log("Autoclick on checkforselects");';
1521 $selectedfields .= ' $("#checkforselects").click();';
1522 $selectedfields .= ' $("#massaction").val("createbills").change();';
1523 $selectedfields .= ' });';
1524 $selectedfields .= '</script>';
1525}
1526
1527print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
1528print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
1529
1530// Fields title search
1531// --------------------------------------------------------------------
1532print '<tr class="liste_titre_filter">';
1533// Action column
1534if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1535 print '<td class="liste_titre center maxwidthsearch">';
1536 $searchpicto = $form->showFilterButtons('left');
1537 print $searchpicto;
1538 print '</td>';
1539}
1540
1541// Ref
1542if (!empty($arrayfields['c.ref']['checked'])) {
1543 print '<td class="liste_titre">';
1544 print '<input class="flat" size="6" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
1545 print '</td>';
1546}
1547// Ref customer
1548if (!empty($arrayfields['c.ref_client']['checked'])) {
1549 print '<td class="liste_titre" align="left">';
1550 print '<input class="flat" type="text" size="6" name="search_ref_customer" value="'.dol_escape_htmltag($search_ref_customer).'">';
1551 print '</td>';
1552}
1553// Project ref
1554if (!empty($arrayfields['p.ref']['checked'])) {
1555 print '<td class="liste_titre"><input type="text" class="flat" size="6" name="search_project_ref" value="'.dol_escape_htmltag($search_project_ref).'"></td>';
1556}
1557// Project title
1558if (!empty($arrayfields['p.title']['checked'])) {
1559 print '<td class="liste_titre"><input type="text" class="flat" size="6" name="search_project" value="'.dol_escape_htmltag($search_project).'"></td>';
1560}
1561// Thirpdarty
1562if (!empty($arrayfields['s.nom']['checked'])) {
1563 print '<td class="liste_titre" align="left">';
1564 print '<input class="flat maxwidth100" type="text" name="search_company" value="'.dol_escape_htmltag($search_company).'">';
1565 print '</td>';
1566}
1567// Alias
1568if (!empty($arrayfields['s.name_alias']['checked'])) {
1569 print '<td class="liste_titre" align="left">';
1570 print '<input class="flat maxwidth100" type="text" name="search_company_alias" value="'.dol_escape_htmltag($search_company_alias).'">';
1571 print '</td>';
1572}
1573// Parent company
1574if (!empty($arrayfields['s2.nom']['checked'])) {
1575 print '<td class="liste_titre">';
1576 print '<input class="flat maxwidth100" type="text" name="search_parent_name" value="'.dol_escape_htmltag($search_parent_name).'">';
1577 print '</td>';
1578}
1579// Town
1580if (!empty($arrayfields['s.town']['checked'])) {
1581 print '<td class="liste_titre"><input class="flat width50" type="text" name="search_town" value="'.dol_escape_htmltag($search_town).'"></td>';
1582}
1583// Zip
1584if (!empty($arrayfields['s.zip']['checked'])) {
1585 print '<td class="liste_titre"><input class="flat width50" type="text" name="search_zip" value="'.dol_escape_htmltag($search_zip).'"></td>';
1586}
1587// State
1588if (!empty($arrayfields['state.nom']['checked'])) {
1589 print '<td class="liste_titre">';
1590 print '<input class="flat width50" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).'">';
1591 print '</td>';
1592}
1593// Country
1594if (!empty($arrayfields['country.code_iso']['checked'])) {
1595 print '<td class="liste_titre" align="center">';
1596 print $form->select_country($search_country, 'search_country', '', 0, 'minwidth100imp maxwidth100');
1597 print '</td>';
1598}
1599// Company type
1600if (!empty($arrayfields['typent.code']['checked'])) {
1601 print '<td class="liste_titre maxwidthonsmartphone" align="center">';
1602 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' : $conf->global->SOCIETE_SORT_ON_TYPEENT), '', 1);
1603 print '</td>';
1604}
1605// Date order
1606if (!empty($arrayfields['c.date_commande']['checked'])) {
1607 print '<td class="liste_titre center">';
1608 print '<div class="nowrapfordate">';
1609 print $form->selectDate($search_dateorder_start ? $search_dateorder_start : -1, 'search_dateorder_start_', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
1610 print '</div>';
1611 print '<div class="nowrapfordate">';
1612 print $form->selectDate($search_dateorder_end ? $search_dateorder_end : -1, 'search_dateorder_end_', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
1613 print '</div>';
1614 print '</td>';
1615}
1616if (!empty($arrayfields['c.date_delivery']['checked'])) {
1617 print '<td class="liste_titre center">';
1618 print '<div class="nowrapfordate">';
1619 print $form->selectDate($search_datedelivery_start ? $search_datedelivery_start : -1, 'search_datedelivery_start_', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
1620 print '</div>';
1621 print '<div class="nowrapfordate">';
1622 print $form->selectDate($search_datedelivery_end ? $search_datedelivery_end : -1, 'search_datedelivery_end_', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
1623 print '</div>';
1624 print '</td>';
1625}
1626// Shipping Method
1627if (!empty($arrayfields['c.fk_shipping_method']['checked'])) {
1628 print '<td class="liste_titre">';
1629 $form->selectShippingMethod($search_fk_shipping_method, 'search_fk_shipping_method', '', 1, '', 1);
1630 print '</td>';
1631}
1632// Payment term
1633if (!empty($arrayfields['c.fk_cond_reglement']['checked'])) {
1634 print '<td class="liste_titre">';
1635 print $form->getSelectConditionsPaiements($search_fk_cond_reglement, 'search_fk_cond_reglement', 1, 1, 1);
1636 print '</td>';
1637}
1638// Payment mode
1639if (!empty($arrayfields['c.fk_mode_reglement']['checked'])) {
1640 print '<td class="liste_titre">';
1641 print $form->select_types_paiements($search_fk_mode_reglement, 'search_fk_mode_reglement', '', 0, 1, 1, 0, -1, '', 1);
1642 print '</td>';
1643}
1644// Channel
1645if (!empty($arrayfields['c.fk_input_reason']['checked'])) {
1646 print '<td class="liste_titre">';
1647 $form->selectInputReason($search_fk_input_reason, 'search_fk_input_reason', '', 1, '', 1);
1648 print '</td>';
1649}
1650// Amount HT / net
1651if (!empty($arrayfields['c.total_ht']['checked'])) {
1652 print '<td class="liste_titre right">';
1653 print '<input class="flat" type="text" size="4" name="search_total_ht" value="'.dol_escape_htmltag($search_total_ht).'">';
1654 print '</td>';
1655}
1656// Amount of VAT
1657if (!empty($arrayfields['c.total_vat']['checked'])) {
1658 print '<td class="liste_titre right">';
1659 print '<input class="flat" type="text" size="4" name="search_total_vat" value="'.dol_escape_htmltag($search_total_vat).'">';
1660 print '</td>';
1661}
1662// Total Amount (TTC / gross)
1663if (!empty($arrayfields['c.total_ttc']['checked'])) {
1664 print '<td class="liste_titre right">';
1665 print '<input class="flat" type="text" size="5" name="search_total_ttc" value="'.$search_total_ttc.'">';
1666 print '</td>';
1667}
1668// Currency
1669if (!empty($arrayfields['c.multicurrency_code']['checked'])) {
1670 print '<td class="liste_titre">';
1671 print $form->selectMultiCurrency($search_multicurrency_code, 'search_multicurrency_code', 1);
1672 print '</td>';
1673}
1674// Currency rate
1675if (!empty($arrayfields['c.multicurrency_tx']['checked'])) {
1676 print '<td class="liste_titre">';
1677 print '<input class="flat" type="text" size="4" name="search_multicurrency_tx" value="'.dol_escape_htmltag($search_multicurrency_tx).'">';
1678 print '</td>';
1679}
1680// Amount HT/net in foreign currency
1681if (!empty($arrayfields['c.multicurrency_total_ht']['checked'])) {
1682 print '<td class="liste_titre right">';
1683 print '<input class="flat" type="text" size="4" name="search_multicurrency_montant_ht" value="'.dol_escape_htmltag($search_multicurrency_montant_ht).'">';
1684 print '</td>';
1685}
1686// VAT in foreign currency
1687if (!empty($arrayfields['c.multicurrency_total_vat']['checked'])) {
1688 print '<td class="liste_titre right">';
1689 print '<input class="flat" type="text" size="4" name="search_multicurrency_montant_vat" value="'.dol_escape_htmltag($search_multicurrency_montant_vat).'">';
1690 print '</td>';
1691}
1692// Amount/Total (TTC / gross) in foreign currency
1693if (!empty($arrayfields['c.multicurrency_total_ttc']['checked'])) {
1694 print '<td class="liste_titre right">';
1695 print '<input class="flat width75" type="text" name="search_multicurrency_montant_ttc" value="'.dol_escape_htmltag($search_multicurrency_montant_ttc).'">';
1696 print '</td>';
1697}
1698// Author
1699if (!empty($arrayfields['u.login']['checked'])) {
1700 print '<td class="liste_titre">';
1701 print '<input class="flat width75" type="text" name="search_login" value="'.dol_escape_htmltag($search_login).'">';
1702 print '</td>';
1703}
1704// Sales Representative
1705if (!empty($arrayfields['sale_representative']['checked'])) {
1706 print '<td class="liste_titre"></td>';
1707}
1708if (!empty($arrayfields['total_pa']['checked'])) {
1709 print '<td class="liste_titre right">';
1710 print '</td>';
1711}
1712if (!empty($arrayfields['total_margin']['checked'])) {
1713 print '<td class="liste_titre right">';
1714 print '</td>';
1715}
1716if (!empty($arrayfields['total_margin_rate']['checked'])) {
1717 print '<td class="liste_titre right">';
1718 print '</td>';
1719}
1720if (!empty($arrayfields['total_mark_rate']['checked'])) {
1721 print '<td class="liste_titre right">';
1722 print '</td>';
1723}
1724
1725// Extra fields
1726include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
1727
1728// Fields from hook
1729$parameters = array('arrayfields'=>$arrayfields);
1730$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1731print $hookmanager->resPrint;
1732
1733// Date creation
1734if (!empty($arrayfields['c.datec']['checked'])) {
1735 print '<td class="liste_titre">';
1736 print '</td>';
1737}
1738// Date modification
1739if (!empty($arrayfields['c.tms']['checked'])) {
1740 print '<td class="liste_titre">';
1741 print '</td>';
1742}
1743// Date cloture
1744if (!empty($arrayfields['c.date_cloture']['checked'])) {
1745 print '<td class="liste_titre center">';
1746 print '<div class="nowrapfordate">';
1747 print $form->selectDate($search_datecloture_start ? $search_datecloture_start : -1, 'search_datecloture_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
1748 print '</div>';
1749 print '<div class="nowrapfordate">';
1750 print $form->selectDate($search_datecloture_end ? $search_datecloture_end : -1, 'search_datecloture_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
1751 print '</div>';
1752 print '</td>';
1753}
1754// Note public
1755if (!empty($arrayfields['c.note_public']['checked'])) {
1756 print '<td class="liste_titre">';
1757 print '</td>';
1758}
1759// Note private
1760if (!empty($arrayfields['c.note_private']['checked'])) {
1761 print '<td class="liste_titre">';
1762 print '</td>';
1763}
1764// Shippable
1765if (!empty($arrayfields['shippable']['checked'])) {
1766 print '<td class="liste_titre maxwidthonsmartphone" align="center">';
1767 //print $form->selectyesno('search_shippable', $search_shippable, 1, 0, 1, 1);
1768 if (getDolGlobalString('ORDER_SHIPABLE_STATUS_DISABLED_BY_DEFAULT')) {
1769 print '<input type="checkbox" name="show_shippable_command" value="1"'.($show_shippable_command ? ' checked' : '').'>';
1770 print $langs->trans('ShowShippableStatus');
1771 } else {
1772 $show_shippable_command = 1;
1773 }
1774 print '</td>';
1775}
1776// Status billed
1777if (!empty($arrayfields['c.facture']['checked'])) {
1778 print '<td class="liste_titre maxwidthonsmartphone center">';
1779 print $form->selectyesno('search_billed', $search_billed, 1, 0, 1, 1);
1780 print '</td>';
1781}
1782// Import key
1783if (!empty($arrayfields['c.import_key']['checked'])) {
1784 print '<td class="liste_titre maxwidthonsmartphone center">';
1785 print '</td>';
1786}
1787// Status
1788if (!empty($arrayfields['c.fk_statut']['checked'])) {
1789 print '<td class="liste_titre center parentonrightofpage">';
1790 $liststatus = array(
1791 Commande::STATUS_DRAFT => $langs->trans("StatusOrderDraftShort"),
1792 Commande::STATUS_VALIDATED => $langs->trans("StatusOrderValidated"),
1793 Commande::STATUS_SHIPMENTONPROCESS => $langs->trans("StatusOrderSentShort"),
1794 -2 => $langs->trans("StatusOrderValidatedShort").'+'.$langs->trans("StatusOrderSentShort"),
1795 -3 => $langs->trans("StatusOrderValidatedShort").'+'.$langs->trans("StatusOrderSentShort").'+'.$langs->trans("StatusOrderDelivered"),
1796 Commande::STATUS_CLOSED => $langs->trans("StatusOrderDelivered"),
1797 Commande::STATUS_CANCELED => $langs->trans("StatusOrderCanceledShort")
1798 );
1799 print $form->selectarray('search_status', $liststatus, $search_status, -5, 0, 0, '', 0, 0, 0, '', 'search_status width100 onrightofpage', 1);
1800 print '</td>';
1801}
1802// Action column
1803if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1804 print '<td class="liste_titre center maxwidthsearch">';
1805 $searchpicto = $form->showFilterButtons();
1806 print $searchpicto;
1807 print '</td>';
1808}
1809print '</tr>'."\n";
1810
1811$totalarray = array(
1812 'nbfield' => 0,
1813 'val' => array(
1814 'c.total_ht' => 0,
1815 'c.total_tva' => 0,
1816 'c.total_ttc' => 0,
1817 ),
1818 'pos' => array(),
1819);
1820
1821
1822// Fields title label
1823// --------------------------------------------------------------------
1824print '<tr class="liste_titre">';
1825
1826// Action column
1827if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1828 print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'maxwidthsearch center ');
1829 $totalarray['nbfield']++;
1830}
1831if (!empty($arrayfields['c.ref']['checked'])) {
1832 print_liste_field_titre($arrayfields['c.ref']['label'], $_SERVER["PHP_SELF"], 'c.ref', '', $param, '', $sortfield, $sortorder);
1833 $totalarray['nbfield']++;
1834}
1835if (!empty($arrayfields['c.ref_client']['checked'])) {
1836 print_liste_field_titre($arrayfields['c.ref_client']['label'], $_SERVER["PHP_SELF"], 'c.ref_client', '', $param, '', $sortfield, $sortorder);
1837 $totalarray['nbfield']++;
1838}
1839if (!empty($arrayfields['p.ref']['checked'])) {
1840 print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], "p.ref", "", $param, '', $sortfield, $sortorder);
1841 $totalarray['nbfield']++;
1842}
1843if (!empty($arrayfields['p.title']['checked'])) {
1844 print_liste_field_titre($arrayfields['p.title']['label'], $_SERVER["PHP_SELF"], "p.title", "", $param, '', $sortfield, $sortorder);
1845 $totalarray['nbfield']++;
1846}
1847if (!empty($arrayfields['s.nom']['checked'])) {
1848 print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], 's.nom', '', $param, '', $sortfield, $sortorder);
1849 $totalarray['nbfield']++;
1850}
1851if (!empty($arrayfields['s.name_alias']['checked'])) {
1852 print_liste_field_titre($arrayfields['s.name_alias']['label'], $_SERVER["PHP_SELF"], 's.name_alias', '', $param, '', $sortfield, $sortorder);
1853 $totalarray['nbfield']++;
1854}
1855if (!empty($arrayfields['s2.nom']['checked'])) {
1856 print_liste_field_titre($arrayfields['s2.nom']['label'], $_SERVER['PHP_SELF'], 's2.nom', '', $param, '', $sortfield, $sortorder);
1857 $totalarray['nbfield']++;
1858}
1859if (!empty($arrayfields['s.town']['checked'])) {
1860 print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], 's.town', '', $param, '', $sortfield, $sortorder);
1861 $totalarray['nbfield']++;
1862}
1863if (!empty($arrayfields['s.zip']['checked'])) {
1864 print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], 's.zip', '', $param, '', $sortfield, $sortorder);
1865 $totalarray['nbfield']++;
1866}
1867if (!empty($arrayfields['state.nom']['checked'])) {
1868 print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder);
1869 $totalarray['nbfield']++;
1870}
1871if (!empty($arrayfields['country.code_iso']['checked'])) {
1872 print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, '', $sortfield, $sortorder, 'center ');
1873 $totalarray['nbfield']++;
1874}
1875if (!empty($arrayfields['typent.code']['checked'])) {
1876 print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, '', $sortfield, $sortorder, 'center ');
1877 $totalarray['nbfield']++;
1878}
1879if (!empty($arrayfields['c.date_commande']['checked'])) {
1880 print_liste_field_titre($arrayfields['c.date_commande']['label'], $_SERVER["PHP_SELF"], 'c.date_commande', '', $param, '', $sortfield, $sortorder, 'center ');
1881 $totalarray['nbfield']++;
1882}
1883if (!empty($arrayfields['c.date_delivery']['checked'])) {
1884 print_liste_field_titre($arrayfields['c.date_delivery']['label'], $_SERVER["PHP_SELF"], 'c.date_livraison', '', $param, '', $sortfield, $sortorder, 'center ');
1885 $totalarray['nbfield']++;
1886}
1887if (!empty($arrayfields['c.fk_shipping_method']['checked'])) {
1888 print_liste_field_titre($arrayfields['c.fk_shipping_method']['label'], $_SERVER["PHP_SELF"], "c.fk_shipping_method", "", $param, '', $sortfield, $sortorder);
1889 $totalarray['nbfield']++;
1890}
1891if (!empty($arrayfields['c.fk_cond_reglement']['checked'])) {
1892 print_liste_field_titre($arrayfields['c.fk_cond_reglement']['label'], $_SERVER["PHP_SELF"], "c.fk_cond_reglement", "", $param, '', $sortfield, $sortorder);
1893 $totalarray['nbfield']++;
1894}
1895if (!empty($arrayfields['c.fk_mode_reglement']['checked'])) {
1896 print_liste_field_titre($arrayfields['c.fk_mode_reglement']['label'], $_SERVER["PHP_SELF"], "c.fk_mode_reglement", "", $param, '', $sortfield, $sortorder);
1897 $totalarray['nbfield']++;
1898}
1899if (!empty($arrayfields['c.fk_input_reason']['checked'])) {
1900 print_liste_field_titre($arrayfields['c.fk_input_reason']['label'], $_SERVER["PHP_SELF"], "c.fk_input_reason", "", $param, '', $sortfield, $sortorder);
1901 $totalarray['nbfield']++;
1902}
1903if (!empty($arrayfields['c.total_ht']['checked'])) {
1904 print_liste_field_titre($arrayfields['c.total_ht']['label'], $_SERVER["PHP_SELF"], 'c.total_ht', '', $param, '', $sortfield, $sortorder, 'right ');
1905 $totalarray['nbfield']++;
1906}
1907if (!empty($arrayfields['c.total_vat']['checked'])) {
1908 print_liste_field_titre($arrayfields['c.total_vat']['label'], $_SERVER["PHP_SELF"], 'c.total_tva', '', $param, '', $sortfield, $sortorder, 'right ');
1909 $totalarray['nbfield']++;
1910}
1911if (!empty($arrayfields['c.total_ttc']['checked'])) {
1912 print_liste_field_titre($arrayfields['c.total_ttc']['label'], $_SERVER["PHP_SELF"], 'c.total_ttc', '', $param, '', $sortfield, $sortorder, 'right ');
1913 $totalarray['nbfield']++;
1914}
1915if (!empty($arrayfields['c.multicurrency_code']['checked'])) {
1916 print_liste_field_titre($arrayfields['c.multicurrency_code']['label'], $_SERVER['PHP_SELF'], 'c.multicurrency_code', '', $param, '', $sortfield, $sortorder);
1917 $totalarray['nbfield']++;
1918}
1919if (!empty($arrayfields['c.multicurrency_tx']['checked'])) {
1920 print_liste_field_titre($arrayfields['c.multicurrency_tx']['label'], $_SERVER['PHP_SELF'], 'c.multicurrency_tx', '', $param, '', $sortfield, $sortorder);
1921 $totalarray['nbfield']++;
1922}
1923if (!empty($arrayfields['c.multicurrency_total_ht']['checked'])) {
1924 print_liste_field_titre($arrayfields['c.multicurrency_total_ht']['label'], $_SERVER['PHP_SELF'], 'c.multicurrency_total_ht', '', $param, 'class="right"', $sortfield, $sortorder);
1925 $totalarray['nbfield']++;
1926}
1927if (!empty($arrayfields['c.multicurrency_total_vat']['checked'])) {
1928 print_liste_field_titre($arrayfields['c.multicurrency_total_vat']['label'], $_SERVER['PHP_SELF'], 'c.multicurrency_total_tva', '', $param, 'class="right"', $sortfield, $sortorder);
1929 $totalarray['nbfield']++;
1930}
1931if (!empty($arrayfields['c.multicurrency_total_ttc']['checked'])) {
1932 print_liste_field_titre($arrayfields['c.multicurrency_total_ttc']['label'], $_SERVER['PHP_SELF'], 'c.multicurrency_total_ttc', '', $param, 'class="right"', $sortfield, $sortorder);
1933 $totalarray['nbfield']++;
1934}
1935if (!empty($arrayfields['u.login']['checked'])) {
1936 print_liste_field_titre($arrayfields['u.login']['label'], $_SERVER["PHP_SELF"], 'u.login', '', $param, '', $sortfield, $sortorder);
1937 $totalarray['nbfield']++;
1938}
1939if (!empty($arrayfields['sale_representative']['checked'])) {
1940 print_liste_field_titre($arrayfields['sale_representative']['label'], $_SERVER["PHP_SELF"], "", "", "$param", '', $sortfield, $sortorder);
1941 $totalarray['nbfield']++;
1942}
1943if (!empty($arrayfields['total_pa']['checked'])) {
1944 print_liste_field_titre($arrayfields['total_pa']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder);
1945 $totalarray['nbfield']++;
1946}
1947if (!empty($arrayfields['total_margin']['checked'])) {
1948 print_liste_field_titre($arrayfields['total_margin']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder);
1949 $totalarray['nbfield']++;
1950}
1951if (!empty($arrayfields['total_margin_rate']['checked'])) {
1952 print_liste_field_titre($arrayfields['total_margin_rate']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder);
1953 $totalarray['nbfield']++;
1954}
1955if (!empty($arrayfields['total_mark_rate']['checked'])) {
1956 print_liste_field_titre($arrayfields['total_mark_rate']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder);
1957 $totalarray['nbfield']++;
1958}
1959
1960// Extra fields
1961include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
1962
1963// Hook fields
1964$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder, 'totalarray'=>&$totalarray);
1965$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1966print $hookmanager->resPrint;
1967if (!empty($arrayfields['c.datec']['checked'])) {
1968 print_liste_field_titre($arrayfields['c.datec']['label'], $_SERVER["PHP_SELF"], "c.date_creation", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
1969 $totalarray['nbfield']++;
1970}
1971if (!empty($arrayfields['c.tms']['checked'])) {
1972 print_liste_field_titre($arrayfields['c.tms']['label'], $_SERVER["PHP_SELF"], "c.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
1973 $totalarray['nbfield']++;
1974}
1975if (!empty($arrayfields['c.date_cloture']['checked'])) {
1976 print_liste_field_titre($arrayfields['c.date_cloture']['label'], $_SERVER["PHP_SELF"], "c.date_cloture", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
1977 $totalarray['nbfield']++;
1978}
1979if (!empty($arrayfields['c.note_public']['checked'])) {
1980 print_liste_field_titre($arrayfields['c.note_public']['label'], $_SERVER["PHP_SELF"], "c.note_public", "", $param, '', $sortfield, $sortorder, 'right ');
1981 $totalarray['nbfield']++;
1982}
1983if (!empty($arrayfields['c.note_private']['checked'])) {
1984 print_liste_field_titre($arrayfields['c.note_private']['label'], $_SERVER["PHP_SELF"], "c.note_private", "", $param, '', $sortfield, $sortorder, 'right ');
1985 $totalarray['nbfield']++;
1986}
1987if (!empty($arrayfields['shippable']['checked'])) {
1988 print_liste_field_titre($arrayfields['shippable']['label'], $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'center ');
1989 $totalarray['nbfield']++;
1990}
1991if (!empty($arrayfields['c.facture']['checked'])) {
1992 print_liste_field_titre($arrayfields['c.facture']['label'], $_SERVER["PHP_SELF"], 'c.facture', '', $param, '', $sortfield, $sortorder, 'center ');
1993 $totalarray['nbfield']++;
1994}
1995if (!empty($arrayfields['c.import_key']['checked'])) {
1996 print_liste_field_titre($arrayfields['c.import_key']['label'], $_SERVER["PHP_SELF"], "c.import_key", "", $param, '', $sortfield, $sortorder, 'center ');
1997 $totalarray['nbfield']++;
1998}
1999if (!empty($arrayfields['c.fk_statut']['checked'])) {
2000 print_liste_field_titre($arrayfields['c.fk_statut']['label'], $_SERVER["PHP_SELF"], "c.fk_statut", "", $param, '', $sortfield, $sortorder, 'center ');
2001 $totalarray['nbfield']++;
2002}
2003// Action column
2004if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
2005 print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'maxwidthsearch center ');
2006 $totalarray['nbfield']++;
2007}
2008print '</tr>'."\n";
2009
2010$total = 0;
2011$subtotal = 0;
2012$productstat_cache = array();
2013$productstat_cachevirtual = array();
2014$getNomUrl_cache = array();
2015
2016$generic_commande = new Commande($db);
2017$generic_product = new Product($db);
2018$userstatic = new User($db);
2019
2020$with_margin_info = false;
2021if (isModEnabled('margin') && (
2022 !empty($arrayfields['total_pa']['checked'])
2023 || !empty($arrayfields['total_margin']['checked'])
2024 || !empty($arrayfields['total_margin_rate']['checked'])
2025 || !empty($arrayfields['total_mark_rate']['checked'])
2026)
2027 ) {
2028 $with_margin_info = true;
2029}
2030
2031 $total_ht = 0;
2032 $total_margin = 0;
2033
2034 // Loop on record
2035 // --------------------------------------------------------------------
2036 $i = 0;
2037 $savnbfield = $totalarray['nbfield'];
2038 $totalarray = array();
2039 $totalarray['nbfield'] = 0;
2040 $imaxinloop = ($limit ? min($num, $limit) : $num);
2041while ($i < $imaxinloop) {
2042 $obj = $db->fetch_object($resql);
2043 if (empty($obj)) {
2044 break; // Should not happen
2045 }
2046
2047 $notshippable = 0;
2048 $warning = 0;
2049 $text_info = '';
2050 $text_warning = '';
2051 $nbprod = 0;
2052
2053 $companystatic->id = $obj->socid;
2054 $companystatic->name = $obj->name;
2055 $companystatic->name_alias = $obj->alias;
2056 $companystatic->client = $obj->client;
2057 $companystatic->fournisseur = $obj->fournisseur;
2058 $companystatic->code_client = $obj->code_client;
2059 $companystatic->email = $obj->email;
2060 $companystatic->phone = $obj->phone;
2061 $companystatic->address = $obj->address;
2062 $companystatic->zip = $obj->zip;
2063 $companystatic->town = $obj->town;
2064 $companystatic->country_code = $obj->country_code;
2065 if (!isset($getNomUrl_cache[$obj->socid])) {
2066 $getNomUrl_cache[$obj->socid] = $companystatic->getNomUrl(1, 'customer', 100, 0, 1, empty($arrayfields['s.name_alias']['checked']) ? 0 : 1);
2067 }
2068
2069 $generic_commande->id = $obj->rowid;
2070 $generic_commande->ref = $obj->ref;
2071 $generic_commande->statut = $obj->fk_statut;
2072 $generic_commande->billed = $obj->billed;
2073 $generic_commande->date = $db->jdate($obj->date_commande);
2074 $generic_commande->delivery_date = $db->jdate($obj->date_delivery);
2075 $generic_commande->ref_client = $obj->ref_client;
2076 $generic_commande->total_ht = $obj->total_ht;
2077 $generic_commande->total_tva = $obj->total_tva;
2078 $generic_commande->total_ttc = $obj->total_ttc;
2079 $generic_commande->note_public = $obj->note_public;
2080 $generic_commande->note_private = $obj->note_private;
2081
2082 $generic_commande->thirdparty = $companystatic;
2083
2084
2085 $projectstatic->id = $obj->project_id;
2086 $projectstatic->ref = $obj->project_ref;
2087 $projectstatic->title = $obj->project_label;
2088
2089 $marginInfo = array();
2090 if ($with_margin_info === true) {
2091 $generic_commande->fetch_lines();
2092 $marginInfo = $formmargin->getMarginInfosArray($generic_commande);
2093 $total_ht += $obj->total_ht;
2094 $total_margin += $marginInfo['total_margin'];
2095 }
2096
2097 if ($mode == 'kanban') {
2098 if ($i == 0) {
2099 print '<tr class="trkanban"><td colspan="'.$savnbfield.'">';
2100 print '<div class="box-flex-container kanban">';
2101 }
2102
2103 // Output Kanban
2104 $selected = -1;
2105 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
2106 $selected = 0;
2107 if (in_array($object->id, $arrayofselected)) {
2108 $selected = 1;
2109 }
2110 }
2111 print $generic_commande->getKanbanView('', array('selected' => $selected));
2112 if ($i == ($imaxinloop - 1)) {
2113 print '</div>';
2114 print '</td></tr>';
2115 }
2116 } else {
2117 // Show line of result
2118 $j = 0;
2119 print '<tr data-rowid="'.$object->id.'" class="oddeven">';
2120
2121 // Action column
2122 if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
2123 print '<td class="nowrap center">';
2124 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
2125 $selected = 0;
2126 if (in_array($obj->rowid, $arrayofselected)) {
2127 $selected = 1;
2128 }
2129 print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
2130 }
2131 print '</td>';
2132 if (!$i) {
2133 $totalarray['nbfield']++;
2134 }
2135 }
2136
2137 // Ref
2138 if (!empty($arrayfields['c.ref']['checked'])) {
2139 print '<td class="nowraponall">';
2140 print $generic_commande->getNomUrl(1, ($search_status != 2 ? 0 : $obj->fk_statut), 0, 0, 0, 1, 1);
2141
2142 $filename = dol_sanitizeFileName($obj->ref);
2143 $filedir = $conf->commande->multidir_output[$conf->entity].'/'.dol_sanitizeFileName($obj->ref);
2144 $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->rowid;
2145 print $formfile->getDocumentsLink($generic_commande->element, $filename, $filedir);
2146
2147 print '</td>';
2148 if (!$i) {
2149 $totalarray['nbfield']++;
2150 }
2151 }
2152
2153 // Ref customer
2154 if (!empty($arrayfields['c.ref_client']['checked'])) {
2155 print '<td class="nowrap tdoverflowmax150" title="'.dol_escape_htmltag($obj->ref_client).'">';
2156 print dol_escape_htmltag($obj->ref_client);
2157 print '</td>';
2158 if (!$i) {
2159 $totalarray['nbfield']++;
2160 }
2161 }
2162
2163 // Project ref
2164 if (!empty($arrayfields['p.ref']['checked'])) {
2165 print '<td class="nowrap">';
2166 if ($obj->project_id > 0) {
2167 print $projectstatic->getNomUrl(1);
2168 }
2169 print '</td>';
2170 if (!$i) {
2171 $totalarray['nbfield']++;
2172 }
2173 }
2174
2175 // Project label
2176 if (!empty($arrayfields['p.title']['checked'])) {
2177 print '<td class="nowrap">';
2178 if ($obj->project_id > 0) {
2179 print $projectstatic->title;
2180 }
2181 print '</td>';
2182 if (!$i) {
2183 $totalarray['nbfield']++;
2184 }
2185 }
2186
2187 // Third party
2188 if (!empty($arrayfields['s.nom']['checked'])) {
2189 print '<td class="tdoverflowmax150">';
2190 if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) {
2191 print $companystatic->getNomUrl(1, 'customer', 100, 0, 1, empty($arrayfields['s.name_alias']['checked']) ? 0 : 1);
2192 } else {
2193 print $getNomUrl_cache[$obj->socid];
2194 }
2195
2196 // If module invoices enabled and user with invoice creation permissions
2197 if (isModEnabled('facture') && getDolGlobalString('ORDER_BILLING_ALL_CUSTOMER')) {
2198 if ($user->hasRight('facture', 'creer')) {
2199 if (($obj->fk_statut > 0 && $obj->fk_statut < 3) || ($obj->fk_statut == 3 && $obj->billed == 0)) {
2200 print '&nbsp;<a href="'.DOL_URL_ROOT.'/commande/list.php?socid='.$companystatic->id.'&search_billed=0&autoselectall=1">';
2201 print img_picto($langs->trans("CreateInvoiceForThisCustomer").' : '.$companystatic->name, 'object_bill', 'hideonsmartphone').'</a>';
2202 }
2203 }
2204 }
2205 print '</td>';
2206 if (!$i) {
2207 $totalarray['nbfield']++;
2208 }
2209 }
2210
2211 // Alias name
2212 if (!empty($arrayfields['s.name_alias']['checked'])) {
2213 print '<td class="tdoverflowmax100" title="'.dol_escape_htmltag($obj->alias).'">';
2214 print dol_escape_htmltag($obj->alias);
2215 print '</td>';
2216 if (!$i) {
2217 $totalarray['nbfield']++;
2218 }
2219 }
2220
2221 // Parent company
2222 if (!empty($arrayfields['s2.nom']['checked'])) {
2223 print '<td class="tdoverflowmax200">';
2224 if ($obj->fk_parent > 0) {
2225 if (!isset($company_url_list[$obj->fk_parent])) {
2226 $companyparent = new Societe($db);
2227 $res = $companyparent->fetch($obj->fk_parent);
2228 if ($res > 0) {
2229 $company_url_list[$obj->fk_parent] = $companyparent->getNomUrl(1);
2230 }
2231 }
2232 if (isset($company_url_list[$obj->fk_parent])) {
2233 print $company_url_list[$obj->fk_parent];
2234 }
2235 }
2236 print "</td>";
2237 if (!$i) {
2238 $totalarray['nbfield']++;
2239 }
2240 }
2241
2242 // Town
2243 if (!empty($arrayfields['s.town']['checked'])) {
2244 print '<td class="tdoverflowmax100" title="'.dol_escape_htmltag($obj->town).'">';
2245 print dol_escape_htmltag($obj->town);
2246 print '</td>';
2247 if (!$i) {
2248 $totalarray['nbfield']++;
2249 }
2250 }
2251
2252 // Zip
2253 if (!empty($arrayfields['s.zip']['checked'])) {
2254 print '<td class="tdoverflowmax100" title="'.dol_escape_htmltag($obj->zip).'">';
2255 print dol_escape_htmltag($obj->zip);
2256 print '</td>';
2257 if (!$i) {
2258 $totalarray['nbfield']++;
2259 }
2260 }
2261
2262 // State
2263 if (!empty($arrayfields['state.nom']['checked'])) {
2264 print '<td class="tdoverflowmax100" title="'.dol_escape_htmltag($obj->state_name).'">'.dol_escape_htmltag($obj->state_name)."</td>\n";
2265 if (!$i) {
2266 $totalarray['nbfield']++;
2267 }
2268 }
2269
2270 // Country
2271 if (!empty($arrayfields['country.code_iso']['checked'])) {
2272 print '<td class="center">';
2273 $tmparray = getCountry($obj->fk_pays, 'all');
2274 print $tmparray['label'];
2275 print '</td>';
2276 if (!$i) {
2277 $totalarray['nbfield']++;
2278 }
2279 }
2280
2281 // Type ent
2282 if (!empty($arrayfields['typent.code']['checked'])) {
2283 print '<td class="center">';
2284 if (empty($typenArray)) {
2285 $typenArray = $formcompany->typent_array(1);
2286 }
2287 print $typenArray[$obj->typent_code]??'';
2288 print '</td>';
2289 if (!$i) {
2290 $totalarray['nbfield']++;
2291 }
2292 }
2293
2294 // Order date
2295 if (!empty($arrayfields['c.date_commande']['checked'])) {
2296 print '<td class="center nowraponall">';
2297 print dol_print_date($db->jdate($obj->date_commande), 'day');
2298 // Warning late icon and note
2299 if ($generic_commande->hasDelay()) {
2300 print img_picto($langs->trans("Late").' : '.$generic_commande->showDelay(), "warning");
2301 }
2302 print '</td>';
2303 if (!$i) {
2304 $totalarray['nbfield']++;
2305 }
2306 }
2307
2308 // Plannned date of delivery
2309 if (!empty($arrayfields['c.date_delivery']['checked'])) {
2310 print '<td class="center nowraponall">';
2311 print dol_print_date($db->jdate($obj->date_delivery), 'dayhour');
2312 print '</td>';
2313 if (!$i) {
2314 $totalarray['nbfield']++;
2315 }
2316 }
2317
2318 // Shipping Method
2319 if (!empty($arrayfields['c.fk_shipping_method']['checked'])) {
2320 print '<td>';
2321 $form->formSelectShippingMethod('', $obj->fk_shipping_method, 'none', 1);
2322 print '</td>';
2323 if (!$i) {
2324 $totalarray['nbfield']++;
2325 }
2326 }
2327
2328 // Payment terms
2329 if (!empty($arrayfields['c.fk_cond_reglement']['checked'])) {
2330 print '<td>';
2331 $form->form_conditions_reglement($_SERVER['PHP_SELF'], $obj->fk_cond_reglement, 'none', 0, '', 1, $obj->deposit_percent);
2332 print '</td>';
2333 if (!$i) {
2334 $totalarray['nbfield']++;
2335 }
2336 }
2337
2338 // Payment mode
2339 if (!empty($arrayfields['c.fk_mode_reglement']['checked'])) {
2340 print '<td>';
2341 $form->form_modes_reglement($_SERVER['PHP_SELF'], $obj->fk_mode_reglement, 'none', '', -1);
2342 print '</td>';
2343 if (!$i) {
2344 $totalarray['nbfield']++;
2345 }
2346 }
2347
2348 // Channel
2349 if (!empty($arrayfields['c.fk_input_reason']['checked'])) {
2350 print '<td>';
2351 $form->formInputReason($_SERVER['PHP_SELF'], $obj->fk_input_reason, 'none', '');
2352 print '</td>';
2353 if (!$i) {
2354 $totalarray['nbfield']++;
2355 }
2356 }
2357
2358 // Amount HT/net
2359 if (!empty($arrayfields['c.total_ht']['checked'])) {
2360 print '<td class="nowrap right"><span class="amount">'.price($obj->total_ht)."</span></td>\n";
2361 if (!$i) {
2362 $totalarray['nbfield']++;
2363 }
2364 if (!$i) {
2365 $totalarray['pos'][$totalarray['nbfield']] = 'c.total_ht';
2366 }
2367 if (isset($totalarray['val']['c.total_ht'])) {
2368 $totalarray['val']['c.total_ht'] += $obj->total_ht;
2369 } else {
2370 $totalarray['val']['c.total_ht'] = $obj->total_ht;
2371 }
2372 }
2373
2374 // Amount VAT
2375 if (!empty($arrayfields['c.total_vat']['checked'])) {
2376 print '<td class="nowrap right"><span class="amount">'.price($obj->total_tva)."</span></td>\n";
2377 if (!$i) {
2378 $totalarray['nbfield']++;
2379 }
2380 if (!$i) {
2381 $totalarray['pos'][$totalarray['nbfield']] = 'c.total_tva';
2382 }
2383 if (isset($totalarray['val']['c.total_tva'])) {
2384 $totalarray['val']['c.total_tva'] += $obj->total_tva;
2385 } else {
2386 $totalarray['val']['c.total_tva'] = $obj->total_tva;
2387 }
2388 }
2389
2390 // Amount TTC / gross
2391 if (!empty($arrayfields['c.total_ttc']['checked'])) {
2392 print '<td class="nowrap right"><span class="amount">'.price($obj->total_ttc)."</span></td>\n";
2393 if (!$i) {
2394 $totalarray['nbfield']++;
2395 }
2396 if (!$i) {
2397 $totalarray['pos'][$totalarray['nbfield']] = 'c.total_ttc';
2398 }
2399 if (isset($totalarray['val']['c.total_ttc'])) {
2400 $totalarray['val']['c.total_ttc'] += $obj->total_ttc;
2401 } else {
2402 $totalarray['val']['c.total_ttc'] = $obj->total_ttc;
2403 }
2404 }
2405
2406 // Currency
2407 if (!empty($arrayfields['c.multicurrency_code']['checked'])) {
2408 print '<td class="nowrap">'.$obj->multicurrency_code.' - '.$langs->trans('Currency'.$obj->multicurrency_code)."</td>\n";
2409 if (!$i) {
2410 $totalarray['nbfield']++;
2411 }
2412 }
2413
2414 // Currency rate
2415 if (!empty($arrayfields['c.multicurrency_tx']['checked'])) {
2416 print '<td class="nowrap">';
2417 $form->form_multicurrency_rate($_SERVER['PHP_SELF'].'?id='.$obj->rowid, $obj->multicurrency_tx, 'none', $obj->multicurrency_code);
2418 print "</td>\n";
2419 if (!$i) {
2420 $totalarray['nbfield']++;
2421 }
2422 }
2423
2424 // Amount HT/net in foreign currency
2425 if (!empty($arrayfields['c.multicurrency_total_ht']['checked'])) {
2426 print '<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_ht)."</span></td>\n";
2427 if (!$i) {
2428 $totalarray['nbfield']++;
2429 }
2430 }
2431 // Amount VAT in foreign currency
2432 if (!empty($arrayfields['c.multicurrency_total_vat']['checked'])) {
2433 print '<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_vat)."</span></td>\n";
2434 if (!$i) {
2435 $totalarray['nbfield']++;
2436 }
2437 }
2438 // Amount TTC / gross in foreign currency
2439 if (!empty($arrayfields['c.multicurrency_total_ttc']['checked'])) {
2440 print '<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_ttc)."</span></td>\n";
2441 if (!$i) {
2442 $totalarray['nbfield']++;
2443 }
2444 }
2445
2446 $userstatic->id = $obj->fk_user_author;
2447 $userstatic->login = $obj->login;
2448 $userstatic->lastname = $obj->lastname;
2449 $userstatic->firstname = $obj->firstname;
2450 $userstatic->email = $obj->user_email;
2451 $userstatic->statut = $obj->user_statut;
2452 $userstatic->entity = $obj->entity;
2453 $userstatic->photo = $obj->photo;
2454 $userstatic->office_phone = $obj->office_phone;
2455 $userstatic->office_fax = $obj->office_fax;
2456 $userstatic->user_mobile = $obj->user_mobile;
2457 $userstatic->job = $obj->job;
2458 $userstatic->gender = $obj->gender;
2459
2460 // Author
2461 if (!empty($arrayfields['u.login']['checked'])) {
2462 print '<td class="tdoverflowmax150">';
2463 if ($userstatic->id) {
2464 print $userstatic->getNomUrl(-1);
2465 } else {
2466 print '&nbsp;';
2467 }
2468 print "</td>\n";
2469 if (!$i) {
2470 $totalarray['nbfield']++;
2471 }
2472 }
2473
2474 // Sales representatives
2475 if (!empty($arrayfields['sale_representative']['checked'])) {
2476 print '<td>';
2477 if ($obj->socid > 0) {
2478 $listsalesrepresentatives = $companystatic->getSalesRepresentatives($user);
2479 if ($listsalesrepresentatives < 0) {
2480 dol_print_error($db);
2481 }
2482 $nbofsalesrepresentative = count($listsalesrepresentatives);
2483 if ($nbofsalesrepresentative > 6) {
2484 // We print only number
2485 print $nbofsalesrepresentative;
2486 } elseif ($nbofsalesrepresentative > 0) {
2487 $j = 0;
2488 foreach ($listsalesrepresentatives as $val) {
2489 $userstatic->id = $val['id'];
2490 $userstatic->lastname = $val['lastname'];
2491 $userstatic->firstname = $val['firstname'];
2492 $userstatic->email = $val['email'];
2493 $userstatic->statut = $val['statut'];
2494 $userstatic->entity = $val['entity'];
2495 $userstatic->photo = $val['photo'];
2496 $userstatic->login = $val['login'];
2497 $userstatic->office_phone = $val['office_phone'];
2498 $userstatic->office_fax = $val['office_fax'];
2499 $userstatic->user_mobile = $val['user_mobile'];
2500 $userstatic->job = $val['job'];
2501 $userstatic->gender = $val['gender'];
2502 //print '<div class="float">':
2503 print ($nbofsalesrepresentative < 2) ? $userstatic->getNomUrl(-1, '', 0, 0, 12) : $userstatic->getNomUrl(-2);
2504 $j++;
2505 if ($j < $nbofsalesrepresentative) {
2506 print ' ';
2507 }
2508 //print '</div>';
2509 }
2510 }
2511 //else print $langs->trans("NoSalesRepresentativeAffected");
2512 } else {
2513 print '&nbsp;';
2514 }
2515 print '</td>';
2516 if (!$i) {
2517 $totalarray['nbfield']++;
2518 }
2519 }
2520
2521 // Total buying or cost price
2522 if (!empty($arrayfields['total_pa']['checked'])) {
2523 print '<td class="right nowrap">'.price($marginInfo['pa_total']).'</td>';
2524 if (!$i) {
2525 $totalarray['nbfield']++;
2526 }
2527 }
2528
2529 // Total margin
2530 if (!empty($arrayfields['total_margin']['checked'])) {
2531 print '<td class="right nowrap">'.price($marginInfo['total_margin']).'</td>';
2532 if (!$i) {
2533 $totalarray['nbfield']++;
2534 }
2535 if (!$i) {
2536 $totalarray['pos'][$totalarray['nbfield']] = 'total_margin';
2537 }
2538
2539 if (!isset($totalarray['val']['total_margin'])) {
2540 $totalarray['val']['total_margin'] = 0;
2541 }
2542
2543 $totalarray['val']['total_margin'] += $marginInfo['total_margin'];
2544 }
2545
2546 // Total margin rate
2547 if (!empty($arrayfields['total_margin_rate']['checked'])) {
2548 print '<td class="right nowrap">'.(($marginInfo['total_margin_rate'] == '') ? '' : price($marginInfo['total_margin_rate'], null, null, null, null, 2).'%').'</td>';
2549 if (!$i) {
2550 $totalarray['nbfield']++;
2551 }
2552 }
2553
2554 // Total mark rate
2555 if (!empty($arrayfields['total_mark_rate']['checked'])) {
2556 print '<td class="right nowrap">'.(($marginInfo['total_mark_rate'] == '') ? '' : price($marginInfo['total_mark_rate'], null, null, null, null, 2).'%').'</td>';
2557 if (!$i) {
2558 $totalarray['nbfield']++;
2559 }
2560 if (!$i) {
2561 $totalarray['pos'][$totalarray['nbfield']] = 'total_mark_rate';
2562 }
2563 if ($i >= $imaxinloop - 1) {
2564 if (!empty($total_ht)) {
2565 $totalarray['val']['total_mark_rate'] = price2num($total_margin * 100 / $total_ht, 'MT');
2566 } else {
2567 $totalarray['val']['total_mark_rate'] = '';
2568 }
2569 }
2570 }
2571
2572 // Extra fields
2573 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
2574 // Fields from hook
2575 $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
2576 $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
2577 print $hookmanager->resPrint;
2578
2579 // Date creation
2580 if (!empty($arrayfields['c.datec']['checked'])) {
2581 print '<td align="center" class="nowrap">';
2582 print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser');
2583 print '</td>';
2584 if (!$i) {
2585 $totalarray['nbfield']++;
2586 }
2587 }
2588
2589 // Date modification
2590 if (!empty($arrayfields['c.tms']['checked'])) {
2591 print '<td align="center" class="nowrap">';
2592 print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser');
2593 print '</td>';
2594 if (!$i) {
2595 $totalarray['nbfield']++;
2596 }
2597 }
2598
2599 // Date cloture
2600 if (!empty($arrayfields['c.date_cloture']['checked'])) {
2601 print '<td align="center" class="nowrap">';
2602 print dol_print_date($db->jdate($obj->date_cloture), 'dayhour', 'tzuser');
2603 print '</td>';
2604 if (!$i) {
2605 $totalarray['nbfield']++;
2606 }
2607 }
2608
2609 // Note public
2610 if (!empty($arrayfields['c.note_public']['checked'])) {
2611 print '<td class="center">';
2612 print dol_string_nohtmltag($obj->note_public);
2613 print '</td>';
2614 if (!$i) {
2615 $totalarray['nbfield']++;
2616 }
2617 }
2618
2619 // Note private
2620 if (!empty($arrayfields['c.note_private']['checked'])) {
2621 print '<td class="center">';
2622 print dol_string_nohtmltag($obj->note_private);
2623 print '</td>';
2624 if (!$i) {
2625 $totalarray['nbfield']++;
2626 }
2627 }
2628
2629 // Show shippable Icon (this creates subloops, so may be slow)
2630 if (!empty($arrayfields['shippable']['checked'])) {
2631 print '<td class="center">';
2632 if (!empty($show_shippable_command) && isModEnabled('stock')) {
2633 if (($obj->fk_statut > $generic_commande::STATUS_DRAFT) && ($obj->fk_statut < $generic_commande::STATUS_CLOSED)) {
2634 $generic_commande->getLinesArray(); // Load array ->lines
2635 $generic_commande->loadExpeditions(); // Load array ->expeditions
2636
2637 $numlines = count($generic_commande->lines); // Loop on each line of order
2638 for ($lig = 0; $lig < $numlines; $lig++) {
2639 if (isset($generic_commande->expeditions[$generic_commande->lines[$lig]->id])) {
2640 $reliquat = $generic_commande->lines[$lig]->qty - $generic_commande->expeditions[$generic_commande->lines[$lig]->id];
2641 } else {
2642 $reliquat = $generic_commande->lines[$lig]->qty;
2643 }
2644 if ($generic_commande->lines[$lig]->product_type == 0 && $generic_commande->lines[$lig]->fk_product > 0) { // If line is a product and not a service
2645 $nbprod++; // order contains real products
2646 $generic_product->id = $generic_commande->lines[$lig]->fk_product;
2647
2648 // Get local and virtual stock and store it into cache
2649 if (empty($productstat_cache[$generic_commande->lines[$lig]->fk_product])) {
2650 $generic_product->load_stock('nobatch,warehouseopen'); // ->load_virtual_stock() is already included into load_stock()
2651 $productstat_cache[$generic_commande->lines[$lig]->fk_product]['stock_reel'] = $generic_product->stock_reel;
2652 $productstat_cachevirtual[$generic_commande->lines[$lig]->fk_product]['stock_reel'] = $generic_product->stock_theorique;
2653 } else {
2654 $generic_product->stock_reel = $productstat_cache[$generic_commande->lines[$lig]->fk_product]['stock_reel'];
2655 $generic_product->stock_theorique = $productstat_cachevirtual[$generic_commande->lines[$lig]->fk_product]['stock_reel'];
2656 }
2657
2658 if ($reliquat > $generic_product->stock_reel) {
2659 $notshippable++;
2660 }
2661 if (!getDolGlobalString('SHIPPABLE_ORDER_ICON_IN_LIST')) { // Default code. Default should be this case.
2662 $text_info .= $reliquat.' x '.$generic_commande->lines[$lig]->product_ref.'&nbsp;'.dol_trunc($generic_commande->lines[$lig]->product_label, 20);
2663 $text_info .= ' - '.$langs->trans("Stock").': <span class="'.($generic_product->stock_reel > 0 ? 'ok' : 'error').'">'.$generic_product->stock_reel.'</span>';
2664 $text_info .= ' - '.$langs->trans("VirtualStock").': <span class="'.($generic_product->stock_theorique > 0 ? 'ok' : 'error').'">'.$generic_product->stock_theorique.'</span>';
2665 $text_info .= ($reliquat != $generic_commande->lines[$lig]->qty ? ' <span class="opacitymedium">('.$langs->trans("QtyInOtherShipments").' '.($generic_commande->lines[$lig]->qty - $reliquat).')</span>' : '');
2666 $text_info .= '<br>';
2667 } else { // BUGGED CODE.
2668 // DOES NOT TAKE INTO ACCOUNT MANUFACTURING. THIS CODE SHOULD BE USELESS. PREVIOUS CODE SEEMS COMPLETE.
2669 // COUNT STOCK WHEN WE SHOULD ALREADY HAVE VALUE
2670 // Detailed virtual stock, looks bugged, uncomplete and need heavy load.
2671 // stock order and stock order_supplier
2672 $stock_order = 0;
2673 $stock_order_supplier = 0;
2674 if (getDolGlobalString('STOCK_CALCULATE_ON_SHIPMENT') || getDolGlobalString('STOCK_CALCULATE_ON_SHIPMENT_CLOSE')) { // What about other options ?
2675 if (isModEnabled('commande')) {
2676 if (empty($productstat_cache[$generic_commande->lines[$lig]->fk_product]['stats_order_customer'])) {
2677 $generic_product->load_stats_commande(0, '1,2');
2678 $productstat_cache[$generic_commande->lines[$lig]->fk_product]['stats_order_customer'] = $generic_product->stats_commande['qty'];
2679 } else {
2680 $generic_product->stats_commande['qty'] = $productstat_cache[$generic_commande->lines[$lig]->fk_product]['stats_order_customer'];
2681 }
2682 $stock_order = $generic_product->stats_commande['qty'];
2683 }
2684 if (isModEnabled("supplier_order")) {
2685 if (empty($productstat_cache[$generic_commande->lines[$lig]->fk_product]['stats_order_supplier'])) {
2686 $generic_product->load_stats_commande_fournisseur(0, '3');
2687 $productstat_cache[$generic_commande->lines[$lig]->fk_product]['stats_order_supplier'] = $generic_product->stats_commande_fournisseur['qty'];
2688 } else {
2689 $generic_product->stats_commande_fournisseur['qty'] = $productstat_cache[$generic_commande->lines[$lig]->fk_product]['stats_order_supplier'];
2690 }
2691 $stock_order_supplier = $generic_product->stats_commande_fournisseur['qty'];
2692 }
2693 }
2694 $text_info .= $reliquat.' x '.$generic_commande->lines[$lig]->ref.'&nbsp;'.dol_trunc($generic_commande->lines[$lig]->product_label, 20);
2695 $text_stock_reel = $generic_product->stock_reel.'/'.$stock_order;
2696 if ($stock_order > $generic_product->stock_reel && !($generic_product->stock_reel < $generic_commande->lines[$lig]->qty)) {
2697 $warning++;
2698 $text_warning .= '<span class="warning">'.$langs->trans('Available').'&nbsp;:&nbsp;'.$text_stock_reel.'</span>';
2699 }
2700 if ($reliquat > $generic_product->stock_reel) {
2701 $text_info .= '<span class="warning">'.$langs->trans('Available').'&nbsp;:&nbsp;'.$text_stock_reel.'</span>';
2702 } else {
2703 $text_info .= '<span class="ok">'.$langs->trans('Available').'&nbsp;:&nbsp;'.$text_stock_reel.'</span>';
2704 }
2705 if (isModEnabled("supplier_order")) {
2706 $text_info .= '&nbsp;'.$langs->trans('SupplierOrder').'&nbsp;:&nbsp;'.$stock_order_supplier;
2707 }
2708 $text_info .= ($reliquat != $generic_commande->lines[$lig]->qty ? ' <span class="opacitymedium">('.$langs->trans("QtyInOtherShipments").' '.($generic_commande->lines[$lig]->qty - $reliquat).')</span>' : '');
2709 $text_info .= '<br>';
2710 }
2711 }
2712 }
2713 if ($notshippable == 0) {
2714 $text_icon = img_picto('', 'dolly', '', false, 0, 0, '', 'green paddingleft');
2715 $text_info = $text_icon.' '.$langs->trans('Shippable').'<br>'.$text_info;
2716 } else {
2717 $text_icon = img_picto('', 'dolly', '', false, 0, 0, '', 'error paddingleft');
2718 $text_info = $text_icon.' '.$langs->trans('NonShippable').'<br>'.$text_info;
2719 }
2720 }
2721
2722 if ($nbprod) {
2723 print $form->textwithtooltip('', $text_info, 2, 1, $text_icon, '', 2);
2724 }
2725 if ($warning) { // Always false in default mode
2726 print $form->textwithtooltip('', $langs->trans('NotEnoughForAllOrders').'<br>'.$text_warning, 2, 1, img_picto('', 'error'), '', 2);
2727 }
2728 }
2729 print '</td>';
2730 if (!$i) {
2731 $totalarray['nbfield']++;
2732 }
2733 }
2734
2735 // Billed
2736 if (!empty($arrayfields['c.facture']['checked'])) {
2737 print '<td class="center">'.yn($obj->billed).'</td>';
2738 if (!$i) {
2739 $totalarray['nbfield']++;
2740 }
2741 }
2742
2743 // Import key
2744 if (!empty($arrayfields['c.import_key']['checked'])) {
2745 print '<td class="nowrap center">'.dol_escape_htmltag($obj->import_key).'</td>';
2746 if (!$i) {
2747 $totalarray['nbfield']++;
2748 }
2749 }
2750
2751 // Status
2752 if (!empty($arrayfields['c.fk_statut']['checked'])) {
2753 print '<td class="nowrap center">'.$generic_commande->LibStatut($obj->fk_statut, $obj->billed, 5, 1).'</td>';
2754 if (!$i) {
2755 $totalarray['nbfield']++;
2756 }
2757 }
2758
2759 // Action column
2760 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
2761 print '<td class="nowrap center">';
2762 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
2763 $selected = 0;
2764 if (in_array($obj->rowid, $arrayofselected)) {
2765 $selected = 1;
2766 }
2767 print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
2768 }
2769 print '</td>';
2770 if (!$i) {
2771 $totalarray['nbfield']++;
2772 }
2773 }
2774
2775 print "</tr>\n";
2776
2777 $total += $obj->total_ht;
2778 $subtotal += $obj->total_ht;
2779 }
2780 $i++;
2781}
2782
2783 // Show total line
2784 include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
2785
2786 // If no record found
2787if ($num == 0) {
2788 $colspan = 1;
2789 foreach ($arrayfields as $key => $val) {
2790 if (!empty($val['checked'])) {
2791 $colspan++;
2792 }
2793 }
2794 print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
2795}
2796
2797 $db->free($resql);
2798
2799 $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql);
2800 $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
2801 print $hookmanager->resPrint;
2802
2803 print '</table>'."\n";
2804 print '</div>'."\n";
2805
2806 print '</form>'."\n";
2807
2808if (in_array('builddoc', array_keys($arrayofmassactions)) && ($nbtotalofrecords === '' || $nbtotalofrecords)) {
2809 $hidegeneratedfilelistifempty = 1;
2810 if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) {
2811 $hidegeneratedfilelistifempty = 0;
2812 }
2813
2814 // Show list of available documents
2815 $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
2816 $urlsource .= str_replace('&amp;', '&', $param);
2817
2818 $filedir = $diroutputmassaction;
2819 $genallowed = $permissiontoread;
2820 $delallowed = $permissiontoadd;
2821
2822 print $formfile->showdocuments('massfilesarea_orders', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
2823}
2824
2825 // End of page
2826 llxFooter();
2827 $db->close();
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Definition wrapper.php:55
llxFooter()
Empty footer.
Definition wrapper.php:69
Class to manage customers orders.
const STATUS_SHIPMENTONPROCESS
Shipment on process.
const STATUS_CLOSED
Closed (Sent, billed or not)
const STATUS_CANCELED
Canceled status.
const STATUS_DRAFT
Draft status.
const STATUS_VALIDATED
Validated status.
Class to manage absolute discounts.
Class to manage standard extra fields.
Class to manage invoices.
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.
Classe permettant la generation de composants html autre Only common components are here.
Classe permettant la generation de composants html autre Only common components are here.
Class with static methods for building HTML components related to products Only components common to ...
Class to manage products or services.
Class to manage projects.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage Dolibarr users.
getCountry($searchkey, $withcode='', $dbtouse=0, $outputlangs='', $entconv=1, $searchlabel='')
Return country label, code or id from an id, code or label.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto='UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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.
natural_search($fields, $value, $mode=0, $nofirstand=0)
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by second index function, which produces ascending (default) or descending output...
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
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...
dolGetButtonTitleSeparator($moreClass="")
Add space between dolGetButtonTitle.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
print_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '…' if string larger than length.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
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...
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.