dolibarr 19.0.3
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 $parameters = array();
1511 $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1512 print $hookmanager->resPrint;
1513 print '</div>';
1514}
1515
1516$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
1517$selectedfields = ($mode != 'kanban' ? $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN', '')) : ''); // This also change content of $arrayfields
1518$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
1519
1520if (GETPOST('autoselectall', 'int')) {
1521 $selectedfields .= '<script>';
1522 $selectedfields .= ' $(document).ready(function() {';
1523 $selectedfields .= ' console.log("Autoclick on checkforselects");';
1524 $selectedfields .= ' $("#checkforselects").click();';
1525 $selectedfields .= ' $("#massaction").val("createbills").change();';
1526 $selectedfields .= ' });';
1527 $selectedfields .= '</script>';
1528}
1529
1530print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
1531print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
1532
1533// Fields title search
1534// --------------------------------------------------------------------
1535print '<tr class="liste_titre_filter">';
1536// Action column
1537if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1538 print '<td class="liste_titre center maxwidthsearch">';
1539 $searchpicto = $form->showFilterButtons('left');
1540 print $searchpicto;
1541 print '</td>';
1542}
1543
1544// Ref
1545if (!empty($arrayfields['c.ref']['checked'])) {
1546 print '<td class="liste_titre">';
1547 print '<input class="flat" size="6" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
1548 print '</td>';
1549}
1550// Ref customer
1551if (!empty($arrayfields['c.ref_client']['checked'])) {
1552 print '<td class="liste_titre" align="left">';
1553 print '<input class="flat" type="text" size="6" name="search_ref_customer" value="'.dol_escape_htmltag($search_ref_customer).'">';
1554 print '</td>';
1555}
1556// Project ref
1557if (!empty($arrayfields['p.ref']['checked'])) {
1558 print '<td class="liste_titre"><input type="text" class="flat" size="6" name="search_project_ref" value="'.dol_escape_htmltag($search_project_ref).'"></td>';
1559}
1560// Project title
1561if (!empty($arrayfields['p.title']['checked'])) {
1562 print '<td class="liste_titre"><input type="text" class="flat" size="6" name="search_project" value="'.dol_escape_htmltag($search_project).'"></td>';
1563}
1564// Thirpdarty
1565if (!empty($arrayfields['s.nom']['checked'])) {
1566 print '<td class="liste_titre" align="left">';
1567 print '<input class="flat maxwidth100" type="text" name="search_company" value="'.dol_escape_htmltag($search_company).'">';
1568 print '</td>';
1569}
1570// Alias
1571if (!empty($arrayfields['s.name_alias']['checked'])) {
1572 print '<td class="liste_titre" align="left">';
1573 print '<input class="flat maxwidth100" type="text" name="search_company_alias" value="'.dol_escape_htmltag($search_company_alias).'">';
1574 print '</td>';
1575}
1576// Parent company
1577if (!empty($arrayfields['s2.nom']['checked'])) {
1578 print '<td class="liste_titre">';
1579 print '<input class="flat maxwidth100" type="text" name="search_parent_name" value="'.dol_escape_htmltag($search_parent_name).'">';
1580 print '</td>';
1581}
1582// Town
1583if (!empty($arrayfields['s.town']['checked'])) {
1584 print '<td class="liste_titre"><input class="flat width50" type="text" name="search_town" value="'.dol_escape_htmltag($search_town).'"></td>';
1585}
1586// Zip
1587if (!empty($arrayfields['s.zip']['checked'])) {
1588 print '<td class="liste_titre"><input class="flat width50" type="text" name="search_zip" value="'.dol_escape_htmltag($search_zip).'"></td>';
1589}
1590// State
1591if (!empty($arrayfields['state.nom']['checked'])) {
1592 print '<td class="liste_titre">';
1593 print '<input class="flat width50" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).'">';
1594 print '</td>';
1595}
1596// Country
1597if (!empty($arrayfields['country.code_iso']['checked'])) {
1598 print '<td class="liste_titre" align="center">';
1599 print $form->select_country($search_country, 'search_country', '', 0, 'minwidth100imp maxwidth100');
1600 print '</td>';
1601}
1602// Company type
1603if (!empty($arrayfields['typent.code']['checked'])) {
1604 print '<td class="liste_titre maxwidthonsmartphone" align="center">';
1605 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);
1606 print '</td>';
1607}
1608// Date order
1609if (!empty($arrayfields['c.date_commande']['checked'])) {
1610 print '<td class="liste_titre center">';
1611 print '<div class="nowrapfordate">';
1612 print $form->selectDate($search_dateorder_start ? $search_dateorder_start : -1, 'search_dateorder_start_', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
1613 print '</div>';
1614 print '<div class="nowrapfordate">';
1615 print $form->selectDate($search_dateorder_end ? $search_dateorder_end : -1, 'search_dateorder_end_', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
1616 print '</div>';
1617 print '</td>';
1618}
1619if (!empty($arrayfields['c.date_delivery']['checked'])) {
1620 print '<td class="liste_titre center">';
1621 print '<div class="nowrapfordate">';
1622 print $form->selectDate($search_datedelivery_start ? $search_datedelivery_start : -1, 'search_datedelivery_start_', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
1623 print '</div>';
1624 print '<div class="nowrapfordate">';
1625 print $form->selectDate($search_datedelivery_end ? $search_datedelivery_end : -1, 'search_datedelivery_end_', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
1626 print '</div>';
1627 print '</td>';
1628}
1629// Shipping Method
1630if (!empty($arrayfields['c.fk_shipping_method']['checked'])) {
1631 print '<td class="liste_titre">';
1632 $form->selectShippingMethod($search_fk_shipping_method, 'search_fk_shipping_method', '', 1, '', 1);
1633 print '</td>';
1634}
1635// Payment term
1636if (!empty($arrayfields['c.fk_cond_reglement']['checked'])) {
1637 print '<td class="liste_titre">';
1638 print $form->getSelectConditionsPaiements($search_fk_cond_reglement, 'search_fk_cond_reglement', 1, 1, 1);
1639 print '</td>';
1640}
1641// Payment mode
1642if (!empty($arrayfields['c.fk_mode_reglement']['checked'])) {
1643 print '<td class="liste_titre">';
1644 print $form->select_types_paiements($search_fk_mode_reglement, 'search_fk_mode_reglement', '', 0, 1, 1, 0, -1, '', 1);
1645 print '</td>';
1646}
1647// Channel
1648if (!empty($arrayfields['c.fk_input_reason']['checked'])) {
1649 print '<td class="liste_titre">';
1650 $form->selectInputReason($search_fk_input_reason, 'search_fk_input_reason', '', 1, '', 1);
1651 print '</td>';
1652}
1653// Amount HT / net
1654if (!empty($arrayfields['c.total_ht']['checked'])) {
1655 print '<td class="liste_titre right">';
1656 print '<input class="flat" type="text" size="4" name="search_total_ht" value="'.dol_escape_htmltag($search_total_ht).'">';
1657 print '</td>';
1658}
1659// Amount of VAT
1660if (!empty($arrayfields['c.total_vat']['checked'])) {
1661 print '<td class="liste_titre right">';
1662 print '<input class="flat" type="text" size="4" name="search_total_vat" value="'.dol_escape_htmltag($search_total_vat).'">';
1663 print '</td>';
1664}
1665// Total Amount (TTC / gross)
1666if (!empty($arrayfields['c.total_ttc']['checked'])) {
1667 print '<td class="liste_titre right">';
1668 print '<input class="flat" type="text" size="5" name="search_total_ttc" value="'.$search_total_ttc.'">';
1669 print '</td>';
1670}
1671// Currency
1672if (!empty($arrayfields['c.multicurrency_code']['checked'])) {
1673 print '<td class="liste_titre">';
1674 print $form->selectMultiCurrency($search_multicurrency_code, 'search_multicurrency_code', 1);
1675 print '</td>';
1676}
1677// Currency rate
1678if (!empty($arrayfields['c.multicurrency_tx']['checked'])) {
1679 print '<td class="liste_titre">';
1680 print '<input class="flat" type="text" size="4" name="search_multicurrency_tx" value="'.dol_escape_htmltag($search_multicurrency_tx).'">';
1681 print '</td>';
1682}
1683// Amount HT/net in foreign currency
1684if (!empty($arrayfields['c.multicurrency_total_ht']['checked'])) {
1685 print '<td class="liste_titre right">';
1686 print '<input class="flat" type="text" size="4" name="search_multicurrency_montant_ht" value="'.dol_escape_htmltag($search_multicurrency_montant_ht).'">';
1687 print '</td>';
1688}
1689// VAT in foreign currency
1690if (!empty($arrayfields['c.multicurrency_total_vat']['checked'])) {
1691 print '<td class="liste_titre right">';
1692 print '<input class="flat" type="text" size="4" name="search_multicurrency_montant_vat" value="'.dol_escape_htmltag($search_multicurrency_montant_vat).'">';
1693 print '</td>';
1694}
1695// Amount/Total (TTC / gross) in foreign currency
1696if (!empty($arrayfields['c.multicurrency_total_ttc']['checked'])) {
1697 print '<td class="liste_titre right">';
1698 print '<input class="flat width75" type="text" name="search_multicurrency_montant_ttc" value="'.dol_escape_htmltag($search_multicurrency_montant_ttc).'">';
1699 print '</td>';
1700}
1701// Author
1702if (!empty($arrayfields['u.login']['checked'])) {
1703 print '<td class="liste_titre">';
1704 print '<input class="flat width75" type="text" name="search_login" value="'.dol_escape_htmltag($search_login).'">';
1705 print '</td>';
1706}
1707// Sales Representative
1708if (!empty($arrayfields['sale_representative']['checked'])) {
1709 print '<td class="liste_titre"></td>';
1710}
1711if (!empty($arrayfields['total_pa']['checked'])) {
1712 print '<td class="liste_titre right">';
1713 print '</td>';
1714}
1715if (!empty($arrayfields['total_margin']['checked'])) {
1716 print '<td class="liste_titre right">';
1717 print '</td>';
1718}
1719if (!empty($arrayfields['total_margin_rate']['checked'])) {
1720 print '<td class="liste_titre right">';
1721 print '</td>';
1722}
1723if (!empty($arrayfields['total_mark_rate']['checked'])) {
1724 print '<td class="liste_titre right">';
1725 print '</td>';
1726}
1727
1728// Extra fields
1729include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
1730
1731// Fields from hook
1732$parameters = array('arrayfields'=>$arrayfields);
1733$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1734print $hookmanager->resPrint;
1735
1736// Date creation
1737if (!empty($arrayfields['c.datec']['checked'])) {
1738 print '<td class="liste_titre">';
1739 print '</td>';
1740}
1741// Date modification
1742if (!empty($arrayfields['c.tms']['checked'])) {
1743 print '<td class="liste_titre">';
1744 print '</td>';
1745}
1746// Date cloture
1747if (!empty($arrayfields['c.date_cloture']['checked'])) {
1748 print '<td class="liste_titre center">';
1749 print '<div class="nowrapfordate">';
1750 print $form->selectDate($search_datecloture_start ? $search_datecloture_start : -1, 'search_datecloture_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
1751 print '</div>';
1752 print '<div class="nowrapfordate">';
1753 print $form->selectDate($search_datecloture_end ? $search_datecloture_end : -1, 'search_datecloture_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
1754 print '</div>';
1755 print '</td>';
1756}
1757// Note public
1758if (!empty($arrayfields['c.note_public']['checked'])) {
1759 print '<td class="liste_titre">';
1760 print '</td>';
1761}
1762// Note private
1763if (!empty($arrayfields['c.note_private']['checked'])) {
1764 print '<td class="liste_titre">';
1765 print '</td>';
1766}
1767// Shippable
1768if (!empty($arrayfields['shippable']['checked'])) {
1769 print '<td class="liste_titre maxwidthonsmartphone" align="center">';
1770 //print $form->selectyesno('search_shippable', $search_shippable, 1, 0, 1, 1);
1771 if (getDolGlobalString('ORDER_SHIPABLE_STATUS_DISABLED_BY_DEFAULT')) {
1772 print '<input type="checkbox" name="show_shippable_command" value="1"'.($show_shippable_command ? ' checked' : '').'>';
1773 print $langs->trans('ShowShippableStatus');
1774 } else {
1775 $show_shippable_command = 1;
1776 }
1777 print '</td>';
1778}
1779// Status billed
1780if (!empty($arrayfields['c.facture']['checked'])) {
1781 print '<td class="liste_titre maxwidthonsmartphone center">';
1782 print $form->selectyesno('search_billed', $search_billed, 1, 0, 1, 1);
1783 print '</td>';
1784}
1785// Import key
1786if (!empty($arrayfields['c.import_key']['checked'])) {
1787 print '<td class="liste_titre maxwidthonsmartphone center">';
1788 print '</td>';
1789}
1790// Status
1791if (!empty($arrayfields['c.fk_statut']['checked'])) {
1792 print '<td class="liste_titre center parentonrightofpage">';
1793 $liststatus = array(
1794 Commande::STATUS_DRAFT => $langs->trans("StatusOrderDraftShort"),
1795 Commande::STATUS_VALIDATED => $langs->trans("StatusOrderValidated"),
1796 Commande::STATUS_SHIPMENTONPROCESS => $langs->trans("StatusOrderSentShort"),
1797 -2 => $langs->trans("StatusOrderValidatedShort").'+'.$langs->trans("StatusOrderSentShort"),
1798 -3 => $langs->trans("StatusOrderValidatedShort").'+'.$langs->trans("StatusOrderSentShort").'+'.$langs->trans("StatusOrderDelivered"),
1799 Commande::STATUS_CLOSED => $langs->trans("StatusOrderDelivered"),
1800 Commande::STATUS_CANCELED => $langs->trans("StatusOrderCanceledShort")
1801 );
1802 print $form->selectarray('search_status', $liststatus, $search_status, -5, 0, 0, '', 0, 0, 0, '', 'search_status width100 onrightofpage', 1);
1803 print '</td>';
1804}
1805// Action column
1806if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1807 print '<td class="liste_titre center maxwidthsearch">';
1808 $searchpicto = $form->showFilterButtons();
1809 print $searchpicto;
1810 print '</td>';
1811}
1812print '</tr>'."\n";
1813
1814$totalarray = array(
1815 'nbfield' => 0,
1816 'val' => array(
1817 'c.total_ht' => 0,
1818 'c.total_tva' => 0,
1819 'c.total_ttc' => 0,
1820 ),
1821 'pos' => array(),
1822);
1823
1824
1825// Fields title label
1826// --------------------------------------------------------------------
1827print '<tr class="liste_titre">';
1828
1829// Action column
1830if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1831 print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'maxwidthsearch center ');
1832 $totalarray['nbfield']++;
1833}
1834if (!empty($arrayfields['c.ref']['checked'])) {
1835 print_liste_field_titre($arrayfields['c.ref']['label'], $_SERVER["PHP_SELF"], 'c.ref', '', $param, '', $sortfield, $sortorder);
1836 $totalarray['nbfield']++;
1837}
1838if (!empty($arrayfields['c.ref_client']['checked'])) {
1839 print_liste_field_titre($arrayfields['c.ref_client']['label'], $_SERVER["PHP_SELF"], 'c.ref_client', '', $param, '', $sortfield, $sortorder);
1840 $totalarray['nbfield']++;
1841}
1842if (!empty($arrayfields['p.ref']['checked'])) {
1843 print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], "p.ref", "", $param, '', $sortfield, $sortorder);
1844 $totalarray['nbfield']++;
1845}
1846if (!empty($arrayfields['p.title']['checked'])) {
1847 print_liste_field_titre($arrayfields['p.title']['label'], $_SERVER["PHP_SELF"], "p.title", "", $param, '', $sortfield, $sortorder);
1848 $totalarray['nbfield']++;
1849}
1850if (!empty($arrayfields['s.nom']['checked'])) {
1851 print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], 's.nom', '', $param, '', $sortfield, $sortorder);
1852 $totalarray['nbfield']++;
1853}
1854if (!empty($arrayfields['s.name_alias']['checked'])) {
1855 print_liste_field_titre($arrayfields['s.name_alias']['label'], $_SERVER["PHP_SELF"], 's.name_alias', '', $param, '', $sortfield, $sortorder);
1856 $totalarray['nbfield']++;
1857}
1858if (!empty($arrayfields['s2.nom']['checked'])) {
1859 print_liste_field_titre($arrayfields['s2.nom']['label'], $_SERVER['PHP_SELF'], 's2.nom', '', $param, '', $sortfield, $sortorder);
1860 $totalarray['nbfield']++;
1861}
1862if (!empty($arrayfields['s.town']['checked'])) {
1863 print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], 's.town', '', $param, '', $sortfield, $sortorder);
1864 $totalarray['nbfield']++;
1865}
1866if (!empty($arrayfields['s.zip']['checked'])) {
1867 print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], 's.zip', '', $param, '', $sortfield, $sortorder);
1868 $totalarray['nbfield']++;
1869}
1870if (!empty($arrayfields['state.nom']['checked'])) {
1871 print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder);
1872 $totalarray['nbfield']++;
1873}
1874if (!empty($arrayfields['country.code_iso']['checked'])) {
1875 print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, '', $sortfield, $sortorder, 'center ');
1876 $totalarray['nbfield']++;
1877}
1878if (!empty($arrayfields['typent.code']['checked'])) {
1879 print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, '', $sortfield, $sortorder, 'center ');
1880 $totalarray['nbfield']++;
1881}
1882if (!empty($arrayfields['c.date_commande']['checked'])) {
1883 print_liste_field_titre($arrayfields['c.date_commande']['label'], $_SERVER["PHP_SELF"], 'c.date_commande', '', $param, '', $sortfield, $sortorder, 'center ');
1884 $totalarray['nbfield']++;
1885}
1886if (!empty($arrayfields['c.date_delivery']['checked'])) {
1887 print_liste_field_titre($arrayfields['c.date_delivery']['label'], $_SERVER["PHP_SELF"], 'c.date_livraison', '', $param, '', $sortfield, $sortorder, 'center ');
1888 $totalarray['nbfield']++;
1889}
1890if (!empty($arrayfields['c.fk_shipping_method']['checked'])) {
1891 print_liste_field_titre($arrayfields['c.fk_shipping_method']['label'], $_SERVER["PHP_SELF"], "c.fk_shipping_method", "", $param, '', $sortfield, $sortorder);
1892 $totalarray['nbfield']++;
1893}
1894if (!empty($arrayfields['c.fk_cond_reglement']['checked'])) {
1895 print_liste_field_titre($arrayfields['c.fk_cond_reglement']['label'], $_SERVER["PHP_SELF"], "c.fk_cond_reglement", "", $param, '', $sortfield, $sortorder);
1896 $totalarray['nbfield']++;
1897}
1898if (!empty($arrayfields['c.fk_mode_reglement']['checked'])) {
1899 print_liste_field_titre($arrayfields['c.fk_mode_reglement']['label'], $_SERVER["PHP_SELF"], "c.fk_mode_reglement", "", $param, '', $sortfield, $sortorder);
1900 $totalarray['nbfield']++;
1901}
1902if (!empty($arrayfields['c.fk_input_reason']['checked'])) {
1903 print_liste_field_titre($arrayfields['c.fk_input_reason']['label'], $_SERVER["PHP_SELF"], "c.fk_input_reason", "", $param, '', $sortfield, $sortorder);
1904 $totalarray['nbfield']++;
1905}
1906if (!empty($arrayfields['c.total_ht']['checked'])) {
1907 print_liste_field_titre($arrayfields['c.total_ht']['label'], $_SERVER["PHP_SELF"], 'c.total_ht', '', $param, '', $sortfield, $sortorder, 'right ');
1908 $totalarray['nbfield']++;
1909}
1910if (!empty($arrayfields['c.total_vat']['checked'])) {
1911 print_liste_field_titre($arrayfields['c.total_vat']['label'], $_SERVER["PHP_SELF"], 'c.total_tva', '', $param, '', $sortfield, $sortorder, 'right ');
1912 $totalarray['nbfield']++;
1913}
1914if (!empty($arrayfields['c.total_ttc']['checked'])) {
1915 print_liste_field_titre($arrayfields['c.total_ttc']['label'], $_SERVER["PHP_SELF"], 'c.total_ttc', '', $param, '', $sortfield, $sortorder, 'right ');
1916 $totalarray['nbfield']++;
1917}
1918if (!empty($arrayfields['c.multicurrency_code']['checked'])) {
1919 print_liste_field_titre($arrayfields['c.multicurrency_code']['label'], $_SERVER['PHP_SELF'], 'c.multicurrency_code', '', $param, '', $sortfield, $sortorder);
1920 $totalarray['nbfield']++;
1921}
1922if (!empty($arrayfields['c.multicurrency_tx']['checked'])) {
1923 print_liste_field_titre($arrayfields['c.multicurrency_tx']['label'], $_SERVER['PHP_SELF'], 'c.multicurrency_tx', '', $param, '', $sortfield, $sortorder);
1924 $totalarray['nbfield']++;
1925}
1926if (!empty($arrayfields['c.multicurrency_total_ht']['checked'])) {
1927 print_liste_field_titre($arrayfields['c.multicurrency_total_ht']['label'], $_SERVER['PHP_SELF'], 'c.multicurrency_total_ht', '', $param, 'class="right"', $sortfield, $sortorder);
1928 $totalarray['nbfield']++;
1929}
1930if (!empty($arrayfields['c.multicurrency_total_vat']['checked'])) {
1931 print_liste_field_titre($arrayfields['c.multicurrency_total_vat']['label'], $_SERVER['PHP_SELF'], 'c.multicurrency_total_tva', '', $param, 'class="right"', $sortfield, $sortorder);
1932 $totalarray['nbfield']++;
1933}
1934if (!empty($arrayfields['c.multicurrency_total_ttc']['checked'])) {
1935 print_liste_field_titre($arrayfields['c.multicurrency_total_ttc']['label'], $_SERVER['PHP_SELF'], 'c.multicurrency_total_ttc', '', $param, 'class="right"', $sortfield, $sortorder);
1936 $totalarray['nbfield']++;
1937}
1938if (!empty($arrayfields['u.login']['checked'])) {
1939 print_liste_field_titre($arrayfields['u.login']['label'], $_SERVER["PHP_SELF"], 'u.login', '', $param, '', $sortfield, $sortorder);
1940 $totalarray['nbfield']++;
1941}
1942if (!empty($arrayfields['sale_representative']['checked'])) {
1943 print_liste_field_titre($arrayfields['sale_representative']['label'], $_SERVER["PHP_SELF"], "", "", "$param", '', $sortfield, $sortorder);
1944 $totalarray['nbfield']++;
1945}
1946if (!empty($arrayfields['total_pa']['checked'])) {
1947 print_liste_field_titre($arrayfields['total_pa']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder);
1948 $totalarray['nbfield']++;
1949}
1950if (!empty($arrayfields['total_margin']['checked'])) {
1951 print_liste_field_titre($arrayfields['total_margin']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder);
1952 $totalarray['nbfield']++;
1953}
1954if (!empty($arrayfields['total_margin_rate']['checked'])) {
1955 print_liste_field_titre($arrayfields['total_margin_rate']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder);
1956 $totalarray['nbfield']++;
1957}
1958if (!empty($arrayfields['total_mark_rate']['checked'])) {
1959 print_liste_field_titre($arrayfields['total_mark_rate']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder);
1960 $totalarray['nbfield']++;
1961}
1962
1963// Extra fields
1964include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
1965
1966// Hook fields
1967$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder, 'totalarray'=>&$totalarray);
1968$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1969print $hookmanager->resPrint;
1970if (!empty($arrayfields['c.datec']['checked'])) {
1971 print_liste_field_titre($arrayfields['c.datec']['label'], $_SERVER["PHP_SELF"], "c.date_creation", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
1972 $totalarray['nbfield']++;
1973}
1974if (!empty($arrayfields['c.tms']['checked'])) {
1975 print_liste_field_titre($arrayfields['c.tms']['label'], $_SERVER["PHP_SELF"], "c.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
1976 $totalarray['nbfield']++;
1977}
1978if (!empty($arrayfields['c.date_cloture']['checked'])) {
1979 print_liste_field_titre($arrayfields['c.date_cloture']['label'], $_SERVER["PHP_SELF"], "c.date_cloture", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
1980 $totalarray['nbfield']++;
1981}
1982if (!empty($arrayfields['c.note_public']['checked'])) {
1983 print_liste_field_titre($arrayfields['c.note_public']['label'], $_SERVER["PHP_SELF"], "c.note_public", "", $param, '', $sortfield, $sortorder, 'right ');
1984 $totalarray['nbfield']++;
1985}
1986if (!empty($arrayfields['c.note_private']['checked'])) {
1987 print_liste_field_titre($arrayfields['c.note_private']['label'], $_SERVER["PHP_SELF"], "c.note_private", "", $param, '', $sortfield, $sortorder, 'right ');
1988 $totalarray['nbfield']++;
1989}
1990if (!empty($arrayfields['shippable']['checked'])) {
1991 print_liste_field_titre($arrayfields['shippable']['label'], $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'center ');
1992 $totalarray['nbfield']++;
1993}
1994if (!empty($arrayfields['c.facture']['checked'])) {
1995 print_liste_field_titre($arrayfields['c.facture']['label'], $_SERVER["PHP_SELF"], 'c.facture', '', $param, '', $sortfield, $sortorder, 'center ');
1996 $totalarray['nbfield']++;
1997}
1998if (!empty($arrayfields['c.import_key']['checked'])) {
1999 print_liste_field_titre($arrayfields['c.import_key']['label'], $_SERVER["PHP_SELF"], "c.import_key", "", $param, '', $sortfield, $sortorder, 'center ');
2000 $totalarray['nbfield']++;
2001}
2002if (!empty($arrayfields['c.fk_statut']['checked'])) {
2003 print_liste_field_titre($arrayfields['c.fk_statut']['label'], $_SERVER["PHP_SELF"], "c.fk_statut", "", $param, '', $sortfield, $sortorder, 'center ');
2004 $totalarray['nbfield']++;
2005}
2006// Action column
2007if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
2008 print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'maxwidthsearch center ');
2009 $totalarray['nbfield']++;
2010}
2011print '</tr>'."\n";
2012
2013$total = 0;
2014$subtotal = 0;
2015$productstat_cache = array();
2016$productstat_cachevirtual = array();
2017$getNomUrl_cache = array();
2018
2019$generic_commande = new Commande($db);
2020$generic_product = new Product($db);
2021$userstatic = new User($db);
2022
2023$with_margin_info = false;
2024if (isModEnabled('margin') && (
2025 !empty($arrayfields['total_pa']['checked'])
2026 || !empty($arrayfields['total_margin']['checked'])
2027 || !empty($arrayfields['total_margin_rate']['checked'])
2028 || !empty($arrayfields['total_mark_rate']['checked'])
2029)
2030 ) {
2031 $with_margin_info = true;
2032}
2033
2034 $total_ht = 0;
2035 $total_margin = 0;
2036
2037 // Loop on record
2038 // --------------------------------------------------------------------
2039 $i = 0;
2040 $savnbfield = $totalarray['nbfield'];
2041 $totalarray = array();
2042 $totalarray['nbfield'] = 0;
2043 $imaxinloop = ($limit ? min($num, $limit) : $num);
2044while ($i < $imaxinloop) {
2045 $obj = $db->fetch_object($resql);
2046 if (empty($obj)) {
2047 break; // Should not happen
2048 }
2049
2050 $notshippable = 0;
2051 $warning = 0;
2052 $text_info = '';
2053 $text_warning = '';
2054 $nbprod = 0;
2055
2056 $companystatic->id = $obj->socid;
2057 $companystatic->name = $obj->name;
2058 $companystatic->name_alias = $obj->alias;
2059 $companystatic->client = $obj->client;
2060 $companystatic->fournisseur = $obj->fournisseur;
2061 $companystatic->code_client = $obj->code_client;
2062 $companystatic->email = $obj->email;
2063 $companystatic->phone = $obj->phone;
2064 $companystatic->address = $obj->address;
2065 $companystatic->zip = $obj->zip;
2066 $companystatic->town = $obj->town;
2067 $companystatic->country_code = $obj->country_code;
2068 if (!isset($getNomUrl_cache[$obj->socid])) {
2069 $getNomUrl_cache[$obj->socid] = $companystatic->getNomUrl(1, 'customer', 100, 0, 1, empty($arrayfields['s.name_alias']['checked']) ? 0 : 1);
2070 }
2071
2072 $generic_commande->id = $obj->rowid;
2073 $generic_commande->ref = $obj->ref;
2074 $generic_commande->statut = $obj->fk_statut;
2075 $generic_commande->billed = $obj->billed;
2076 $generic_commande->date = $db->jdate($obj->date_commande);
2077 $generic_commande->delivery_date = $db->jdate($obj->date_delivery);
2078 $generic_commande->ref_client = $obj->ref_client;
2079 $generic_commande->total_ht = $obj->total_ht;
2080 $generic_commande->total_tva = $obj->total_tva;
2081 $generic_commande->total_ttc = $obj->total_ttc;
2082 $generic_commande->note_public = $obj->note_public;
2083 $generic_commande->note_private = $obj->note_private;
2084
2085 $generic_commande->thirdparty = $companystatic;
2086
2087
2088 $projectstatic->id = $obj->project_id;
2089 $projectstatic->ref = $obj->project_ref;
2090 $projectstatic->title = $obj->project_label;
2091
2092 $marginInfo = array();
2093 if ($with_margin_info === true) {
2094 $generic_commande->fetch_lines();
2095 $marginInfo = $formmargin->getMarginInfosArray($generic_commande);
2096 $total_ht += $obj->total_ht;
2097 $total_margin += $marginInfo['total_margin'];
2098 }
2099
2100 if ($mode == 'kanban') {
2101 if ($i == 0) {
2102 print '<tr class="trkanban"><td colspan="'.$savnbfield.'">';
2103 print '<div class="box-flex-container kanban">';
2104 }
2105
2106 // Output Kanban
2107 $selected = -1;
2108 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
2109 $selected = 0;
2110 if (in_array($object->id, $arrayofselected)) {
2111 $selected = 1;
2112 }
2113 }
2114 print $generic_commande->getKanbanView('', array('selected' => $selected));
2115 if ($i == ($imaxinloop - 1)) {
2116 print '</div>';
2117 print '</td></tr>';
2118 }
2119 } else {
2120 // Show line of result
2121 $j = 0;
2122 print '<tr data-rowid="'.$object->id.'" class="oddeven">';
2123
2124 // Action column
2125 if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
2126 print '<td class="nowrap center">';
2127 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
2128 $selected = 0;
2129 if (in_array($obj->rowid, $arrayofselected)) {
2130 $selected = 1;
2131 }
2132 print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
2133 }
2134 print '</td>';
2135 if (!$i) {
2136 $totalarray['nbfield']++;
2137 }
2138 }
2139
2140 // Ref
2141 if (!empty($arrayfields['c.ref']['checked'])) {
2142 print '<td class="nowraponall">';
2143 print $generic_commande->getNomUrl(1, ($search_status != 2 ? 0 : $obj->fk_statut), 0, 0, 0, 1, 1);
2144
2145 $filename = dol_sanitizeFileName($obj->ref);
2146 $filedir = $conf->commande->multidir_output[$conf->entity].'/'.dol_sanitizeFileName($obj->ref);
2147 $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->rowid;
2148 print $formfile->getDocumentsLink($generic_commande->element, $filename, $filedir);
2149
2150 print '</td>';
2151 if (!$i) {
2152 $totalarray['nbfield']++;
2153 }
2154 }
2155
2156 // Ref customer
2157 if (!empty($arrayfields['c.ref_client']['checked'])) {
2158 print '<td class="nowrap tdoverflowmax150" title="'.dol_escape_htmltag($obj->ref_client).'">';
2159 print dol_escape_htmltag($obj->ref_client);
2160 print '</td>';
2161 if (!$i) {
2162 $totalarray['nbfield']++;
2163 }
2164 }
2165
2166 // Project ref
2167 if (!empty($arrayfields['p.ref']['checked'])) {
2168 print '<td class="nowrap">';
2169 if ($obj->project_id > 0) {
2170 print $projectstatic->getNomUrl(1);
2171 }
2172 print '</td>';
2173 if (!$i) {
2174 $totalarray['nbfield']++;
2175 }
2176 }
2177
2178 // Project label
2179 if (!empty($arrayfields['p.title']['checked'])) {
2180 print '<td class="nowrap">';
2181 if ($obj->project_id > 0) {
2182 print $projectstatic->title;
2183 }
2184 print '</td>';
2185 if (!$i) {
2186 $totalarray['nbfield']++;
2187 }
2188 }
2189
2190 // Third party
2191 if (!empty($arrayfields['s.nom']['checked'])) {
2192 print '<td class="tdoverflowmax150">';
2193 if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) {
2194 print $companystatic->getNomUrl(1, 'customer', 100, 0, 1, empty($arrayfields['s.name_alias']['checked']) ? 0 : 1);
2195 } else {
2196 print $getNomUrl_cache[$obj->socid];
2197 }
2198
2199 // If module invoices enabled and user with invoice creation permissions
2200 if (isModEnabled('facture') && getDolGlobalString('ORDER_BILLING_ALL_CUSTOMER')) {
2201 if ($user->hasRight('facture', 'creer')) {
2202 if (($obj->fk_statut > 0 && $obj->fk_statut < 3) || ($obj->fk_statut == 3 && $obj->billed == 0)) {
2203 print '&nbsp;<a href="'.DOL_URL_ROOT.'/commande/list.php?socid='.$companystatic->id.'&search_billed=0&autoselectall=1">';
2204 print img_picto($langs->trans("CreateInvoiceForThisCustomer").' : '.$companystatic->name, 'object_bill', 'hideonsmartphone').'</a>';
2205 }
2206 }
2207 }
2208 print '</td>';
2209 if (!$i) {
2210 $totalarray['nbfield']++;
2211 }
2212 }
2213
2214 // Alias name
2215 if (!empty($arrayfields['s.name_alias']['checked'])) {
2216 print '<td class="nocellnopadd">';
2217 print $obj->alias;
2218 print '</td>';
2219 if (!$i) {
2220 $totalarray['nbfield']++;
2221 }
2222 }
2223
2224 // Parent company
2225 if (!empty($arrayfields['s2.nom']['checked'])) {
2226 print '<td class="tdoverflowmax200">';
2227 if ($obj->fk_parent > 0) {
2228 if (!isset($company_url_list[$obj->fk_parent])) {
2229 $companyparent = new Societe($db);
2230 $res = $companyparent->fetch($obj->fk_parent);
2231 if ($res > 0) {
2232 $company_url_list[$obj->fk_parent] = $companyparent->getNomUrl(1);
2233 }
2234 }
2235 if (isset($company_url_list[$obj->fk_parent])) {
2236 print $company_url_list[$obj->fk_parent];
2237 }
2238 }
2239 print "</td>";
2240 if (!$i) {
2241 $totalarray['nbfield']++;
2242 }
2243 }
2244
2245 // Town
2246 if (!empty($arrayfields['s.town']['checked'])) {
2247 print '<td class="nocellnopadd">';
2248 print $obj->town;
2249 print '</td>';
2250 if (!$i) {
2251 $totalarray['nbfield']++;
2252 }
2253 }
2254
2255 // Zip
2256 if (!empty($arrayfields['s.zip']['checked'])) {
2257 print '<td class="nocellnopadd">';
2258 print $obj->zip;
2259 print '</td>';
2260 if (!$i) {
2261 $totalarray['nbfield']++;
2262 }
2263 }
2264
2265 // State
2266 if (!empty($arrayfields['state.nom']['checked'])) {
2267 print "<td>".$obj->state_name."</td>\n";
2268 if (!$i) {
2269 $totalarray['nbfield']++;
2270 }
2271 }
2272
2273 // Country
2274 if (!empty($arrayfields['country.code_iso']['checked'])) {
2275 print '<td class="center">';
2276 $tmparray = getCountry($obj->fk_pays, 'all');
2277 print $tmparray['label'];
2278 print '</td>';
2279 if (!$i) {
2280 $totalarray['nbfield']++;
2281 }
2282 }
2283
2284 // Type ent
2285 if (!empty($arrayfields['typent.code']['checked'])) {
2286 print '<td class="center">';
2287 if (empty($typenArray)) {
2288 $typenArray = $formcompany->typent_array(1);
2289 }
2290 print $typenArray[$obj->typent_code]??'';
2291 print '</td>';
2292 if (!$i) {
2293 $totalarray['nbfield']++;
2294 }
2295 }
2296
2297 // Order date
2298 if (!empty($arrayfields['c.date_commande']['checked'])) {
2299 print '<td class="center nowraponall">';
2300 print dol_print_date($db->jdate($obj->date_commande), 'day');
2301 // Warning late icon and note
2302 if ($generic_commande->hasDelay()) {
2303 print img_picto($langs->trans("Late").' : '.$generic_commande->showDelay(), "warning");
2304 }
2305 print '</td>';
2306 if (!$i) {
2307 $totalarray['nbfield']++;
2308 }
2309 }
2310
2311 // Plannned date of delivery
2312 if (!empty($arrayfields['c.date_delivery']['checked'])) {
2313 print '<td class="center nowraponall">';
2314 print dol_print_date($db->jdate($obj->date_delivery), 'dayhour');
2315 print '</td>';
2316 if (!$i) {
2317 $totalarray['nbfield']++;
2318 }
2319 }
2320
2321 // Shipping Method
2322 if (!empty($arrayfields['c.fk_shipping_method']['checked'])) {
2323 print '<td>';
2324 $form->formSelectShippingMethod('', $obj->fk_shipping_method, 'none', 1);
2325 print '</td>';
2326 if (!$i) {
2327 $totalarray['nbfield']++;
2328 }
2329 }
2330
2331 // Payment terms
2332 if (!empty($arrayfields['c.fk_cond_reglement']['checked'])) {
2333 print '<td>';
2334 $form->form_conditions_reglement($_SERVER['PHP_SELF'], $obj->fk_cond_reglement, 'none', 0, '', 1, $obj->deposit_percent);
2335 print '</td>';
2336 if (!$i) {
2337 $totalarray['nbfield']++;
2338 }
2339 }
2340
2341 // Payment mode
2342 if (!empty($arrayfields['c.fk_mode_reglement']['checked'])) {
2343 print '<td>';
2344 $form->form_modes_reglement($_SERVER['PHP_SELF'], $obj->fk_mode_reglement, 'none', '', -1);
2345 print '</td>';
2346 if (!$i) {
2347 $totalarray['nbfield']++;
2348 }
2349 }
2350
2351 // Channel
2352 if (!empty($arrayfields['c.fk_input_reason']['checked'])) {
2353 print '<td>';
2354 $form->formInputReason($_SERVER['PHP_SELF'], $obj->fk_input_reason, 'none', '');
2355 print '</td>';
2356 if (!$i) {
2357 $totalarray['nbfield']++;
2358 }
2359 }
2360
2361 // Amount HT/net
2362 if (!empty($arrayfields['c.total_ht']['checked'])) {
2363 print '<td class="nowrap right"><span class="amount">'.price($obj->total_ht)."</span></td>\n";
2364 if (!$i) {
2365 $totalarray['nbfield']++;
2366 }
2367 if (!$i) {
2368 $totalarray['pos'][$totalarray['nbfield']] = 'c.total_ht';
2369 }
2370 if (isset($totalarray['val']['c.total_ht'])) {
2371 $totalarray['val']['c.total_ht'] += $obj->total_ht;
2372 } else {
2373 $totalarray['val']['c.total_ht'] = $obj->total_ht;
2374 }
2375 }
2376
2377 // Amount VAT
2378 if (!empty($arrayfields['c.total_vat']['checked'])) {
2379 print '<td class="nowrap right"><span class="amount">'.price($obj->total_tva)."</span></td>\n";
2380 if (!$i) {
2381 $totalarray['nbfield']++;
2382 }
2383 if (!$i) {
2384 $totalarray['pos'][$totalarray['nbfield']] = 'c.total_tva';
2385 }
2386 if (isset($totalarray['val']['c.total_tva'])) {
2387 $totalarray['val']['c.total_tva'] += $obj->total_tva;
2388 } else {
2389 $totalarray['val']['c.total_tva'] = $obj->total_tva;
2390 }
2391 }
2392
2393 // Amount TTC / gross
2394 if (!empty($arrayfields['c.total_ttc']['checked'])) {
2395 print '<td class="nowrap right"><span class="amount">'.price($obj->total_ttc)."</span></td>\n";
2396 if (!$i) {
2397 $totalarray['nbfield']++;
2398 }
2399 if (!$i) {
2400 $totalarray['pos'][$totalarray['nbfield']] = 'c.total_ttc';
2401 }
2402 if (isset($totalarray['val']['c.total_ttc'])) {
2403 $totalarray['val']['c.total_ttc'] += $obj->total_ttc;
2404 } else {
2405 $totalarray['val']['c.total_ttc'] = $obj->total_ttc;
2406 }
2407 }
2408
2409 // Currency
2410 if (!empty($arrayfields['c.multicurrency_code']['checked'])) {
2411 print '<td class="nowrap">'.$obj->multicurrency_code.' - '.$langs->trans('Currency'.$obj->multicurrency_code)."</td>\n";
2412 if (!$i) {
2413 $totalarray['nbfield']++;
2414 }
2415 }
2416
2417 // Currency rate
2418 if (!empty($arrayfields['c.multicurrency_tx']['checked'])) {
2419 print '<td class="nowrap">';
2420 $form->form_multicurrency_rate($_SERVER['PHP_SELF'].'?id='.$obj->rowid, $obj->multicurrency_tx, 'none', $obj->multicurrency_code);
2421 print "</td>\n";
2422 if (!$i) {
2423 $totalarray['nbfield']++;
2424 }
2425 }
2426
2427 // Amount HT/net in foreign currency
2428 if (!empty($arrayfields['c.multicurrency_total_ht']['checked'])) {
2429 print '<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_ht)."</span></td>\n";
2430 if (!$i) {
2431 $totalarray['nbfield']++;
2432 }
2433 }
2434 // Amount VAT in foreign currency
2435 if (!empty($arrayfields['c.multicurrency_total_vat']['checked'])) {
2436 print '<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_vat)."</span></td>\n";
2437 if (!$i) {
2438 $totalarray['nbfield']++;
2439 }
2440 }
2441 // Amount TTC / gross in foreign currency
2442 if (!empty($arrayfields['c.multicurrency_total_ttc']['checked'])) {
2443 print '<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_ttc)."</span></td>\n";
2444 if (!$i) {
2445 $totalarray['nbfield']++;
2446 }
2447 }
2448
2449 $userstatic->id = $obj->fk_user_author;
2450 $userstatic->login = $obj->login;
2451 $userstatic->lastname = $obj->lastname;
2452 $userstatic->firstname = $obj->firstname;
2453 $userstatic->email = $obj->user_email;
2454 $userstatic->statut = $obj->user_statut;
2455 $userstatic->entity = $obj->entity;
2456 $userstatic->photo = $obj->photo;
2457 $userstatic->office_phone = $obj->office_phone;
2458 $userstatic->office_fax = $obj->office_fax;
2459 $userstatic->user_mobile = $obj->user_mobile;
2460 $userstatic->job = $obj->job;
2461 $userstatic->gender = $obj->gender;
2462
2463 // Author
2464 if (!empty($arrayfields['u.login']['checked'])) {
2465 print '<td class="tdoverflowmax150">';
2466 if ($userstatic->id) {
2467 print $userstatic->getNomUrl(-1);
2468 } else {
2469 print '&nbsp;';
2470 }
2471 print "</td>\n";
2472 if (!$i) {
2473 $totalarray['nbfield']++;
2474 }
2475 }
2476
2477 // Sales representatives
2478 if (!empty($arrayfields['sale_representative']['checked'])) {
2479 print '<td>';
2480 if ($obj->socid > 0) {
2481 $listsalesrepresentatives = $companystatic->getSalesRepresentatives($user);
2482 if ($listsalesrepresentatives < 0) {
2483 dol_print_error($db);
2484 }
2485 $nbofsalesrepresentative = count($listsalesrepresentatives);
2486 if ($nbofsalesrepresentative > 6) {
2487 // We print only number
2488 print $nbofsalesrepresentative;
2489 } elseif ($nbofsalesrepresentative > 0) {
2490 $j = 0;
2491 foreach ($listsalesrepresentatives as $val) {
2492 $userstatic->id = $val['id'];
2493 $userstatic->lastname = $val['lastname'];
2494 $userstatic->firstname = $val['firstname'];
2495 $userstatic->email = $val['email'];
2496 $userstatic->statut = $val['statut'];
2497 $userstatic->entity = $val['entity'];
2498 $userstatic->photo = $val['photo'];
2499 $userstatic->login = $val['login'];
2500 $userstatic->office_phone = $val['office_phone'];
2501 $userstatic->office_fax = $val['office_fax'];
2502 $userstatic->user_mobile = $val['user_mobile'];
2503 $userstatic->job = $val['job'];
2504 $userstatic->gender = $val['gender'];
2505 //print '<div class="float">':
2506 print ($nbofsalesrepresentative < 2) ? $userstatic->getNomUrl(-1, '', 0, 0, 12) : $userstatic->getNomUrl(-2);
2507 $j++;
2508 if ($j < $nbofsalesrepresentative) {
2509 print ' ';
2510 }
2511 //print '</div>';
2512 }
2513 }
2514 //else print $langs->trans("NoSalesRepresentativeAffected");
2515 } else {
2516 print '&nbsp;';
2517 }
2518 print '</td>';
2519 if (!$i) {
2520 $totalarray['nbfield']++;
2521 }
2522 }
2523
2524 // Total buying or cost price
2525 if (!empty($arrayfields['total_pa']['checked'])) {
2526 print '<td class="right nowrap">'.price($marginInfo['pa_total']).'</td>';
2527 if (!$i) {
2528 $totalarray['nbfield']++;
2529 }
2530 }
2531
2532 // Total margin
2533 if (!empty($arrayfields['total_margin']['checked'])) {
2534 print '<td class="right nowrap">'.price($marginInfo['total_margin']).'</td>';
2535 if (!$i) {
2536 $totalarray['nbfield']++;
2537 }
2538 if (!$i) {
2539 $totalarray['pos'][$totalarray['nbfield']] = 'total_margin';
2540 }
2541
2542 if (!isset($totalarray['val']['total_margin'])) {
2543 $totalarray['val']['total_margin'] = 0;
2544 }
2545
2546 $totalarray['val']['total_margin'] += $marginInfo['total_margin'];
2547 }
2548
2549 // Total margin rate
2550 if (!empty($arrayfields['total_margin_rate']['checked'])) {
2551 print '<td class="right nowrap">'.(($marginInfo['total_margin_rate'] == '') ? '' : price($marginInfo['total_margin_rate'], null, null, null, null, 2).'%').'</td>';
2552 if (!$i) {
2553 $totalarray['nbfield']++;
2554 }
2555 }
2556
2557 // Total mark rate
2558 if (!empty($arrayfields['total_mark_rate']['checked'])) {
2559 print '<td class="right nowrap">'.(($marginInfo['total_mark_rate'] == '') ? '' : price($marginInfo['total_mark_rate'], null, null, null, null, 2).'%').'</td>';
2560 if (!$i) {
2561 $totalarray['nbfield']++;
2562 }
2563 if (!$i) {
2564 $totalarray['pos'][$totalarray['nbfield']] = 'total_mark_rate';
2565 }
2566 if ($i >= $imaxinloop - 1) {
2567 if (!empty($total_ht)) {
2568 $totalarray['val']['total_mark_rate'] = price2num($total_margin * 100 / $total_ht, 'MT');
2569 } else {
2570 $totalarray['val']['total_mark_rate'] = '';
2571 }
2572 }
2573 }
2574
2575 // Extra fields
2576 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
2577 // Fields from hook
2578 $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
2579 $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
2580 print $hookmanager->resPrint;
2581
2582 // Date creation
2583 if (!empty($arrayfields['c.datec']['checked'])) {
2584 print '<td align="center" class="nowrap">';
2585 print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser');
2586 print '</td>';
2587 if (!$i) {
2588 $totalarray['nbfield']++;
2589 }
2590 }
2591
2592 // Date modification
2593 if (!empty($arrayfields['c.tms']['checked'])) {
2594 print '<td align="center" class="nowrap">';
2595 print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser');
2596 print '</td>';
2597 if (!$i) {
2598 $totalarray['nbfield']++;
2599 }
2600 }
2601
2602 // Date cloture
2603 if (!empty($arrayfields['c.date_cloture']['checked'])) {
2604 print '<td align="center" class="nowrap">';
2605 print dol_print_date($db->jdate($obj->date_cloture), 'dayhour', 'tzuser');
2606 print '</td>';
2607 if (!$i) {
2608 $totalarray['nbfield']++;
2609 }
2610 }
2611
2612 // Note public
2613 if (!empty($arrayfields['c.note_public']['checked'])) {
2614 print '<td class="center">';
2615 print dol_string_nohtmltag($obj->note_public);
2616 print '</td>';
2617 if (!$i) {
2618 $totalarray['nbfield']++;
2619 }
2620 }
2621
2622 // Note private
2623 if (!empty($arrayfields['c.note_private']['checked'])) {
2624 print '<td class="center">';
2625 print dol_string_nohtmltag($obj->note_private);
2626 print '</td>';
2627 if (!$i) {
2628 $totalarray['nbfield']++;
2629 }
2630 }
2631
2632 // Show shippable Icon (this creates subloops, so may be slow)
2633 if (!empty($arrayfields['shippable']['checked'])) {
2634 print '<td class="center">';
2635 if (!empty($show_shippable_command) && isModEnabled('stock')) {
2636 if (($obj->fk_statut > $generic_commande::STATUS_DRAFT) && ($obj->fk_statut < $generic_commande::STATUS_CLOSED)) {
2637 $generic_commande->getLinesArray(); // Load array ->lines
2638 $generic_commande->loadExpeditions(); // Load array ->expeditions
2639
2640 $numlines = count($generic_commande->lines); // Loop on each line of order
2641 for ($lig = 0; $lig < $numlines; $lig++) {
2642 if (isset($generic_commande->expeditions[$generic_commande->lines[$lig]->id])) {
2643 $reliquat = $generic_commande->lines[$lig]->qty - $generic_commande->expeditions[$generic_commande->lines[$lig]->id];
2644 } else {
2645 $reliquat = $generic_commande->lines[$lig]->qty;
2646 }
2647 if ($generic_commande->lines[$lig]->product_type == 0 && $generic_commande->lines[$lig]->fk_product > 0) { // If line is a product and not a service
2648 $nbprod++; // order contains real products
2649 $generic_product->id = $generic_commande->lines[$lig]->fk_product;
2650
2651 // Get local and virtual stock and store it into cache
2652 if (empty($productstat_cache[$generic_commande->lines[$lig]->fk_product])) {
2653 $generic_product->load_stock('nobatch,warehouseopen'); // ->load_virtual_stock() is already included into load_stock()
2654 $productstat_cache[$generic_commande->lines[$lig]->fk_product]['stock_reel'] = $generic_product->stock_reel;
2655 $productstat_cachevirtual[$generic_commande->lines[$lig]->fk_product]['stock_reel'] = $generic_product->stock_theorique;
2656 } else {
2657 $generic_product->stock_reel = $productstat_cache[$generic_commande->lines[$lig]->fk_product]['stock_reel'];
2658 $generic_product->stock_theorique = $productstat_cachevirtual[$generic_commande->lines[$lig]->fk_product]['stock_reel'] = $generic_product->stock_theorique;
2659 }
2660
2661 if ($reliquat > $generic_product->stock_reel) {
2662 $notshippable++;
2663 }
2664 if (!getDolGlobalString('SHIPPABLE_ORDER_ICON_IN_LIST')) { // Default code. Default should be this case.
2665 $text_info .= $reliquat.' x '.$generic_commande->lines[$lig]->product_ref.'&nbsp;'.dol_trunc($generic_commande->lines[$lig]->product_label, 20);
2666 $text_info .= ' - '.$langs->trans("Stock").': <span class="'.($generic_product->stock_reel > 0 ? 'ok' : 'error').'">'.$generic_product->stock_reel.'</span>';
2667 $text_info .= ' - '.$langs->trans("VirtualStock").': <span class="'.($generic_product->stock_theorique > 0 ? 'ok' : 'error').'">'.$generic_product->stock_theorique.'</span>';
2668 $text_info .= ($reliquat != $generic_commande->lines[$lig]->qty ? ' <span class="opacitymedium">('.$langs->trans("QtyInOtherShipments").' '.($generic_commande->lines[$lig]->qty - $reliquat).')</span>' : '');
2669 $text_info .= '<br>';
2670 } else { // BUGGED CODE.
2671 // DOES NOT TAKE INTO ACCOUNT MANUFACTURING. THIS CODE SHOULD BE USELESS. PREVIOUS CODE SEEMS COMPLETE.
2672 // COUNT STOCK WHEN WE SHOULD ALREADY HAVE VALUE
2673 // Detailed virtual stock, looks bugged, uncomplete and need heavy load.
2674 // stock order and stock order_supplier
2675 $stock_order = 0;
2676 $stock_order_supplier = 0;
2677 if (getDolGlobalString('STOCK_CALCULATE_ON_SHIPMENT') || getDolGlobalString('STOCK_CALCULATE_ON_SHIPMENT_CLOSE')) { // What about other options ?
2678 if (isModEnabled('commande')) {
2679 if (empty($productstat_cache[$generic_commande->lines[$lig]->fk_product]['stats_order_customer'])) {
2680 $generic_product->load_stats_commande(0, '1,2');
2681 $productstat_cache[$generic_commande->lines[$lig]->fk_product]['stats_order_customer'] = $generic_product->stats_commande['qty'];
2682 } else {
2683 $generic_product->stats_commande['qty'] = $productstat_cache[$generic_commande->lines[$lig]->fk_product]['stats_order_customer'];
2684 }
2685 $stock_order = $generic_product->stats_commande['qty'];
2686 }
2687 if (isModEnabled("supplier_order")) {
2688 if (empty($productstat_cache[$generic_commande->lines[$lig]->fk_product]['stats_order_supplier'])) {
2689 $generic_product->load_stats_commande_fournisseur(0, '3');
2690 $productstat_cache[$generic_commande->lines[$lig]->fk_product]['stats_order_supplier'] = $generic_product->stats_commande_fournisseur['qty'];
2691 } else {
2692 $generic_product->stats_commande_fournisseur['qty'] = $productstat_cache[$generic_commande->lines[$lig]->fk_product]['stats_order_supplier'];
2693 }
2694 $stock_order_supplier = $generic_product->stats_commande_fournisseur['qty'];
2695 }
2696 }
2697 $text_info .= $reliquat.' x '.$generic_commande->lines[$lig]->ref.'&nbsp;'.dol_trunc($generic_commande->lines[$lig]->product_label, 20);
2698 $text_stock_reel = $generic_product->stock_reel.'/'.$stock_order;
2699 if ($stock_order > $generic_product->stock_reel && !($generic_product->stock_reel < $generic_commande->lines[$lig]->qty)) {
2700 $warning++;
2701 $text_warning .= '<span class="warning">'.$langs->trans('Available').'&nbsp;:&nbsp;'.$text_stock_reel.'</span>';
2702 }
2703 if ($reliquat > $generic_product->stock_reel) {
2704 $text_info .= '<span class="warning">'.$langs->trans('Available').'&nbsp;:&nbsp;'.$text_stock_reel.'</span>';
2705 } else {
2706 $text_info .= '<span class="ok">'.$langs->trans('Available').'&nbsp;:&nbsp;'.$text_stock_reel.'</span>';
2707 }
2708 if (isModEnabled("supplier_order")) {
2709 $text_info .= '&nbsp;'.$langs->trans('SupplierOrder').'&nbsp;:&nbsp;'.$stock_order_supplier;
2710 }
2711 $text_info .= ($reliquat != $generic_commande->lines[$lig]->qty ? ' <span class="opacitymedium">('.$langs->trans("QtyInOtherShipments").' '.($generic_commande->lines[$lig]->qty - $reliquat).')</span>' : '');
2712 $text_info .= '<br>';
2713 }
2714 }
2715 }
2716 if ($notshippable == 0) {
2717 $text_icon = img_picto('', 'dolly', '', false, 0, 0, '', 'green paddingleft');
2718 $text_info = $text_icon.' '.$langs->trans('Shippable').'<br>'.$text_info;
2719 } else {
2720 $text_icon = img_picto('', 'dolly', '', false, 0, 0, '', 'error paddingleft');
2721 $text_info = $text_icon.' '.$langs->trans('NonShippable').'<br>'.$text_info;
2722 }
2723 }
2724
2725 if ($nbprod) {
2726 print $form->textwithtooltip('', $text_info, 2, 1, $text_icon, '', 2);
2727 }
2728 if ($warning) { // Always false in default mode
2729 print $form->textwithtooltip('', $langs->trans('NotEnoughForAllOrders').'<br>'.$text_warning, 2, 1, img_picto('', 'error'), '', 2);
2730 }
2731 }
2732 print '</td>';
2733 if (!$i) {
2734 $totalarray['nbfield']++;
2735 }
2736 }
2737
2738 // Billed
2739 if (!empty($arrayfields['c.facture']['checked'])) {
2740 print '<td class="center">'.yn($obj->billed).'</td>';
2741 if (!$i) {
2742 $totalarray['nbfield']++;
2743 }
2744 }
2745
2746 // Import key
2747 if (!empty($arrayfields['c.import_key']['checked'])) {
2748 print '<td class="nowrap center">'.dol_escape_htmltag($obj->import_key).'</td>';
2749 if (!$i) {
2750 $totalarray['nbfield']++;
2751 }
2752 }
2753
2754 // Status
2755 if (!empty($arrayfields['c.fk_statut']['checked'])) {
2756 print '<td class="nowrap center">'.$generic_commande->LibStatut($obj->fk_statut, $obj->billed, 5, 1).'</td>';
2757 if (!$i) {
2758 $totalarray['nbfield']++;
2759 }
2760 }
2761
2762 // Action column
2763 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
2764 print '<td class="nowrap center">';
2765 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
2766 $selected = 0;
2767 if (in_array($obj->rowid, $arrayofselected)) {
2768 $selected = 1;
2769 }
2770 print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
2771 }
2772 print '</td>';
2773 if (!$i) {
2774 $totalarray['nbfield']++;
2775 }
2776 }
2777
2778 print "</tr>\n";
2779
2780 $total += $obj->total_ht;
2781 $subtotal += $obj->total_ht;
2782 }
2783 $i++;
2784}
2785
2786 // Show total line
2787 include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
2788
2789 // If no record found
2790if ($num == 0) {
2791 $colspan = 1;
2792 foreach ($arrayfields as $key => $val) {
2793 if (!empty($val['checked'])) {
2794 $colspan++;
2795 }
2796 }
2797 print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
2798}
2799
2800 $db->free($resql);
2801
2802 $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql);
2803 $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
2804 print $hookmanager->resPrint;
2805
2806 print '</table>'."\n";
2807 print '</div>'."\n";
2808
2809 print '</form>'."\n";
2810
2811if (in_array('builddoc', array_keys($arrayofmassactions)) && ($nbtotalofrecords === '' || $nbtotalofrecords)) {
2812 $hidegeneratedfilelistifempty = 1;
2813 if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) {
2814 $hidegeneratedfilelistifempty = 0;
2815 }
2816
2817 // Show list of available documents
2818 $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
2819 $urlsource .= str_replace('&amp;', '&', $param);
2820
2821 $filedir = $diroutputmassaction;
2822 $genallowed = $permissiontoread;
2823 $delallowed = $permissiontoadd;
2824
2825 print $formfile->showdocuments('massfilesarea_orders', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
2826}
2827
2828 // End of page
2829 llxFooter();
2830 $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.