dolibarr  19.0.0-dev
list_det.php
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-2021 Ferran Marcet <fmarcet@2byte.es>
13  * Copyright (C) 2018 Charlene Benke <charlie@patas-monkey.com>
14  * Copyright (C) 2021-2022 Anthony Berton <anthony.berton@bb2a.fr>
15  *
16  * This program is free software; you can redistribute it and/or modify
17  * it under the terms of the GNU General Public License as published by
18  * the Free Software Foundation; either version 3 of the License, or
19  * (at your option) any later version.
20  *
21  * This program is distributed in the hope that it will be useful,
22  * but WITHOUT ANY WARRANTY; without even the implied warranty of
23  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24  * GNU General Public License for more details.
25  *
26  * You should have received a copy of the GNU General Public License
27  * along with this program. If not, see <https://www.gnu.org/licenses/>.
28  */
29 
36 require '../main.inc.php';
37 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
38 require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
39 require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php';
40 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
41 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
42 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
43 if (isModEnabled('margin')) {
44  require_once DOL_DOCUMENT_ROOT.'/core/class/html.formmargin.class.php';
45 }
46 require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
47 require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
48 require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
49 require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
50 
51 // Load translation files required by the page
52 $langs->loadLangs(array("orders", 'sendings', 'deliveries', 'companies', 'compta', 'bills', 'stocks', 'products'));
53 
54 $action = GETPOST('action', 'aZ09');
55 $massaction = GETPOST('massaction', 'alpha');
56 $show_files = GETPOST('show_files', 'int');
57 $confirm = GETPOST('confirm', 'alpha');
58 $toselect = GETPOST('toselect', 'array');
59 $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'orderlistdet';
60 $productobuy = GETPOST('productobuy', 'alpha');
61 $productonly = GETPOST('productonly', 'alpha');
62 $disablelinefree = GETPOST('disablelinefree', 'alpha');
63 
64 $search_datecloture_start = GETPOST('search_datecloture_start', 'int');
65 if (empty($search_datecloture_start)) {
66  $search_datecloture_start = dol_mktime(0, 0, 0, GETPOST('search_datecloture_startmonth', 'int'), GETPOST('search_datecloture_startday', 'int'), GETPOST('search_datecloture_startyear', 'int'));
67 }
68 $search_datecloture_end = GETPOST('search_datecloture_end', 'int');
69 if (empty($search_datecloture_end)) {
70  $search_datecloture_end = dol_mktime(23, 59, 59, GETPOST('search_datecloture_endmonth', 'int'), GETPOST('search_datecloture_endday', 'int'), GETPOST('search_datecloture_endyear', 'int'));
71 }
72 $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'));
73 $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'));
74 $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'));
75 $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'));
76 $search_product_category = GETPOST('search_product_category', 'int');
77 
78 // Détail commande
79 $search_refProduct = GETPOST('search_refProduct', 'alpha');
80 $search_descProduct = GETPOST('search_descProduct', 'alpha');
81 
82 $search_ref = GETPOST('search_ref', 'alpha') != '' ?GETPOST('search_ref', 'alpha') : GETPOST('sref', 'alpha');
83 $search_ref_customer = GETPOST('search_ref_customer', 'alpha');
84 $search_company = GETPOST('search_company', 'alpha');
85 $search_company_alias = GETPOST('search_company_alias', 'alpha');
86 $search_town = GETPOST('search_town', 'alpha');
87 $search_zip = GETPOST('search_zip', 'alpha');
88 $search_state = GETPOST("search_state", 'alpha');
89 $search_country = GETPOST("search_country", 'int');
90 $search_type_thirdparty = GETPOST("search_type_thirdparty", 'int');
91 $sall = trim((GETPOST('search_all', 'alphanohtml') != '') ? GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml'));
92 $socid = GETPOST('socid', '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 $search_multicurrency_code = GETPOST('search_multicurrency_code', 'alpha');
100 $search_multicurrency_tx = GETPOST('search_multicurrency_tx', 'alpha');
101 $search_multicurrency_montant_ht = GETPOST('search_multicurrency_montant_ht', 'alpha');
102 $search_multicurrency_montant_vat = GETPOST('search_multicurrency_montant_vat', 'alpha');
103 $search_multicurrency_montant_ttc = GETPOST('search_multicurrency_montant_ttc', 'alpha');
104 $search_login = GETPOST('search_login', 'alpha');
105 $search_categ_cus = GETPOST("search_categ_cus", 'int');
106 $optioncss = GETPOST('optioncss', 'alpha');
107 $search_billed = GETPOSTISSET('search_billed') ? GETPOST('search_billed', 'int') : GETPOST('billed', 'int');
108 $search_status = GETPOST('search_status', 'int');
109 $search_btn = GETPOST('button_search', 'alpha');
110 $search_remove_btn = GETPOST('button_removefilter', 'alpha');
111 $search_project_ref = GETPOST('search_project_ref', 'alpha');
112 $search_project = GETPOST('search_project', 'alpha');
113 $search_shippable = GETPOST('search_shippable', 'aZ09');
114 $search_fk_cond_reglement = GETPOST("search_fk_cond_reglement", 'int');
115 $search_fk_shipping_method = GETPOST("search_fk_shipping_method", 'int');
116 $search_fk_mode_reglement = GETPOST("search_fk_mode_reglement", 'int');
117 $search_fk_input_reason = GETPOST("search_fk_input_reason", 'int');
118 
119 // Security check
120 $id = (GETPOST('orderid') ?GETPOST('orderid', 'int') : GETPOST('id', 'int'));
121 if ($user->socid) {
122  $socid = $user->socid;
123 }
124 $result = restrictedArea($user, 'commande', $id, '');
125 
126 $diroutputmassaction = $conf->commande->multidir_output[$conf->entity].'/temp/massgeneration/'.$user->id;
127 
128 // Load variable for pagination
129 $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
130 $sortfield = GETPOST('sortfield', 'aZ09comma');
131 $sortorder = GETPOST('sortorder', 'aZ09comma');
132 $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
133 if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
134  $page = 0;
135 } // If $page is not defined, or '' or -1 or if we click on clear filters
136 $offset = $limit * $page;
137 $pageprev = $page - 1;
138 $pagenext = $page + 1;
139 if (!$sortfield) {
140  $sortfield = 'pr.ref';
141 }
142 if (!$sortorder) {
143  $sortorder = 'ASC';
144 }
145 
146 $show_shippable_command = GETPOST('show_shippable_command', 'aZ09');
147 
148 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
149 $object = new Commande($db);
150 $hookmanager->initHooks(array('orderlistdetail'));
151 $extrafields = new ExtraFields($db);
152 
153 // fetch optionals attributes and labels
154 $extrafields->fetch_name_optionals_label($object->table_element);
155 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
156 
157 // List of fields to search into when doing a "search in all"
158 $fieldstosearchall = array(
159  'c.ref'=>'Ref',
160  'c.ref_client'=>'RefCustomerOrder',
161  'pd.description'=>'Description',
162  's.nom'=>"ThirdParty",
163  's.name_alias'=>"AliasNameShort",
164  's.zip'=>"Zip",
165  's.town'=>"Town",
166  'c.note_public'=>'NotePublic',
167 );
168 if (empty($user->socid)) {
169  $fieldstosearchall["c.note_private"] = "NotePrivate";
170 }
171 
172 $checkedtypetiers = 0;
173 $arrayfields = array(
174  // Détail commande
175  'pr.ref'=> array('label'=>'ProductRef', 'checked'=>1, 'position'=>1),
176  'pr.desc'=> array('label'=>'ProductDescription', 'checked'=>1, 'position'=>1),
177  'cdet.qty'=> array('label'=>'QtyOrdered', 'checked'=>1, 'position'=>1),
178  'c.ref'=>array('label'=>"Ref", 'checked'=>1, 'position'=>5),
179  'c.ref_client'=>array('label'=>"RefCustomerOrder", 'checked'=>-1, 'position'=>10),
180  'p.ref'=>array('label'=>"ProjectRef", 'checked'=>-1, 'enabled'=>(empty($conf->project->enabled) ? 0 : 1), 'position'=>20),
181  'p.title'=>array('label'=>"ProjectLabel", 'checked'=>0, 'enabled'=>(empty($conf->project->enabled) ? 0 : 1), 'position'=>25),
182  's.nom'=>array('label'=>"ThirdParty", 'checked'=>1, 'position'=>30),
183  's.name_alias'=>array('label'=>"AliasNameShort", 'checked'=>-1, 'position'=>31),
184  's.town'=>array('label'=>"Town", 'checked'=>-1, 'position'=>35),
185  's.zip'=>array('label'=>"Zip", 'checked'=>-1, 'position'=>40),
186  'state.nom'=>array('label'=>"StateShort", 'checked'=>0, 'position'=>45),
187  'country.code_iso'=>array('label'=>"Country", 'checked'=>0, 'position'=>50),
188  'typent.code'=>array('label'=>"ThirdPartyType", 'checked'=>$checkedtypetiers, 'position'=>55),
189  'c.date_commande'=>array('label'=>"OrderDateShort", 'checked'=>1, 'position'=>60),
190  'c.date_delivery'=>array('label'=>"DateDeliveryPlanned", 'checked'=>1, 'enabled'=>empty($conf->global->ORDER_DISABLE_DELIVERY_DATE), 'position'=>65),
191  'c.fk_shipping_method'=>array('label'=>"SendingMethod", 'checked'=>-1, 'position'=>66 , 'enabled'=>isModEnabled('expedition')),
192  'c.fk_cond_reglement'=>array('label'=>"PaymentConditionsShort", 'checked'=>-1, 'position'=>67),
193  'c.fk_mode_reglement'=>array('label'=>"PaymentMode", 'checked'=>-1, 'position'=>68),
194  'c.fk_input_reason'=>array('label'=>"Channel", 'checked'=>-1, 'position'=>69),
195  'cdet.total_ht'=>array('label'=>"AmountHT", 'checked'=>1, 'position'=>75),
196  'c.total_vat'=>array('label'=>"AmountVAT", 'checked'=>0, 'position'=>80),
197  'cdet.total_ttc'=>array('label'=>"AmountTTC", 'checked'=>0, 'position'=>85),
198  'c.multicurrency_code'=>array('label'=>'Currency', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1), 'position'=>90),
199  'c.multicurrency_tx'=>array('label'=>'CurrencyRate', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1), 'position'=>95),
200  'c.multicurrency_total_ht'=>array('label'=>'MulticurrencyAmountHT', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1), 'position'=>100),
201  'c.multicurrency_total_vat'=>array('label'=>'MulticurrencyAmountVAT', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1), 'position'=>105),
202  'c.multicurrency_total_ttc'=>array('label'=>'MulticurrencyAmountTTC', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1), 'position'=>110),
203  'c.fk_warehouse'=>array('label'=>'Warehouse', 'checked'=>0, 'enabled'=>(!isModEnabled('stock') && empty($conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER) ? 0 : 1), 'position'=>110),
204  'u.login'=>array('label'=>"Author", 'checked'=>1, 'position'=>115),
205  'sale_representative'=>array('label'=>"SaleRepresentativesOfThirdParty", 'checked'=>0, 'position'=>116),
206  'total_pa' => array('label' => (getDolGlobalString('MARGIN_TYPE') == '1' ? 'BuyingPrice' : 'CostPrice'), 'checked' => 0, 'position' => 300, 'enabled' => (!isModEnabled('margin') || !$user->rights->margins->liretous ? 0 : 1)),
207  'total_margin' => array('label' => 'Margin', 'checked' => 0, 'position' => 301, 'enabled' => (!isModEnabled('margin') || !$user->rights->margins->liretous ? 0 : 1)),
208  'total_margin_rate' => array('label' => 'MarginRate', 'checked' => 0, 'position' => 302, 'enabled' => (!isModEnabled('margin') || !$user->rights->margins->liretous || empty($conf->global->DISPLAY_MARGIN_RATES) ? 0 : 1)),
209  'total_mark_rate' => array('label' => 'MarkRate', 'checked' => 0, 'position' => 303, 'enabled' => (!isModEnabled('margin') || !$user->rights->margins->liretous || empty($conf->global->DISPLAY_MARK_RATES) ? 0 : 1)),
210  'c.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>120),
211  'c.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>125),
212  'c.date_cloture'=>array('label'=>"DateClosing", 'checked'=>0, 'position'=>130),
213  'c.note_public'=>array('label'=>'NotePublic', 'checked'=>0, 'enabled'=>(empty($conf->global->MAIN_LIST_ALLOW_PUBLIC_NOTES)), 'position'=>135),
214  'c.note_private'=>array('label'=>'NotePrivate', 'checked'=>0, 'enabled'=>(empty($conf->global->MAIN_LIST_ALLOW_PRIVATE_NOTES)), 'position'=>140),
215  'shippable'=>array('label'=>"Shippable", 'checked'=>1,'enabled'=>(isModEnabled('expedition')), 'position'=>990),
216  'c.facture'=>array('label'=>"Billed", 'checked'=>1, 'enabled'=>(empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT)), 'position'=>995),
217  'c.import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'position'=>999),
218  'c.fk_statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000)
219 );
220 
221 // Extra fields
222 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
223 
224 $object->fields = dol_sort_array($object->fields, 'position');
225 $arrayfields = dol_sort_array($arrayfields, 'position');
226 
227 
228 
229 /*
230  * Actions
231  */
232 
233 if (GETPOST('cancel', 'alpha')) {
234  $action = 'list'; $massaction = '';
235 }
236 if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createbills') {
237  $massaction = '';
238 }
239 
240 $parameters = array('socid'=>$socid);
241 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
242 if ($reshook < 0) {
243  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
244 }
245 
246 if (empty($reshook)) {
247  // Selection of new fields
248  include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
249 
250  // Purge search criteria
251  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
252  $productobuy = '';
253  $productonly = '';
254  $disablelinefree = '';
255  $search_categ = '';
256  $search_user = '';
257  $search_sale = '';
258  $search_product_category = '';
259  $search_refProduct = '';
260  $search_descProduct = '';
261  $search_ref = '';
262  $search_ref_customer = '';
263  $search_company = '';
264  $search_company_alias = '';
265  $search_town = '';
266  $search_zip = "";
267  $search_state = "";
268  $search_type = '';
269  $search_country = '';
270  $search_type_thirdparty = '';
271  $search_total_ht = '';
272  $search_total_vat = '';
273  $search_total_ttc = '';
274  $search_warehouse = '';
275  $search_multicurrency_code = '';
276  $search_multicurrency_tx = '';
277  $search_multicurrency_montant_ht = '';
278  $search_multicurrency_montant_vat = '';
279  $search_multicurrency_montant_ttc = '';
280  $search_login = '';
281  $search_dateorder_start = '';
282  $search_dateorder_end = '';
283  $search_datedelivery_start = '';
284  $search_datedelivery_end = '';
285  $search_project_ref = '';
286  $search_project = '';
287  $search_status = '';
288  $search_billed = '';
289  $toselect = array();
290  $search_array_options = array();
291  $search_categ_cus = 0;
292  $search_datecloture_start = '';
293  $search_datecloture_end = '';
294  $search_fk_cond_reglement = '';
295  $search_fk_shipping_method = '';
296  $search_fk_mode_reglement = '';
297  $search_fk_input_reason = '';
298  }
299  if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')
300  || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) {
301  $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation
302  }
303 
304  // Mass actions
305  $objectclass = 'Commande';
306  $objectlabel = 'Orders';
307  $permissiontoread = $user->rights->commande->lire;
308  $permissiontoadd = $user->rights->commande->creer;
309  $permissiontodelete = $user->rights->commande->supprimer;
310  if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS)) {
311  $permissiontovalidate = $user->rights->commande->order_advance->validate;
312  $permissiontoclose = $user->rights->commande->order_advance->close;
313  $permissiontocancel = $user->rights->commande->order_advance->annuler;
314  $permissiontosendbymail = $user->rights->commande->order_advance->send;
315  } else {
316  $permissiontovalidate = $user->rights->commande->creer;
317  $permissiontoclose = $user->rights->commande->creer;
318  $permissiontocancel = $user->rights->commande->creer;
319  $permissiontosendbymail = $user->rights->commande->creer;
320  }
321  $uploaddir = $conf->commande->multidir_output[$conf->entity];
322  $triggersendname = 'ORDER_SENTBYMAIL';
323  include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
324 }
325 
326 // Closed records
327 // if (!$error && $massaction === 'setbilled' && $permissiontoclose) {
328 
329 // }
330 
331 /*
332  * View
333  */
334 
335 $now = dol_now();
336 
337 $form = new Form($db);
338 $formother = new FormOther($db);
339 $formfile = new FormFile($db);
340 $formmargin = null;
341 if (isModEnabled('margin')) {
342  $formmargin = new FormMargin($db);
343 }
344 $companystatic = new Societe($db);
345 $formcompany = new FormCompany($db);
346 $projectstatic = new Project($db);
347 
348 $title = $langs->trans("Orders");
349 $help_url = "EN:Module_Customers_Orders|FR:Module_Commandes_Clients|ES:Módulo_Pedidos_de_clientes";
350 // llxHeader('',$title,$help_url);
351 
352 $sql = 'SELECT';
353 if ($sall || $search_product_category > 0 || $search_user > 0) {
354  $sql = 'SELECT DISTINCT';
355 }
356 $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.code_client,';
357 $sql .= " typent.code as typent_code,";
358 $sql .= " state.code_departement as state_code, state.nom as state_name,";
359 $sql .= " country.code as country_code,";
360 $sql .= ' c.rowid as c_rowid, c.ref, c.ref_client, c.fk_user_author,';
361 $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,';
362 $sql .= ' c.total_ht as c_total_ht, c.total_tva as c_total_tva, c.total_ttc as c_total_ttc, c.fk_warehouse as warehouse,';
363 $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,';
364 $sql .= ' c.date_creation as date_creation, c.tms as date_update, c.date_cloture as date_cloture,';
365 $sql .= ' p.rowid as project_id, p.ref as project_ref, p.title as project_label,';
366 $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,';
367 $sql .= ' c.fk_cond_reglement,c.deposit_percent,c.fk_mode_reglement,c.fk_shipping_method,';
368 $sql .= ' c.fk_input_reason, c.import_key';
369 
370 // Détail commande
371 $sql .= ', cdet.rowid, cdet.description, cdet.qty, cdet.product_type, cdet.fk_product, cdet.total_ht, cdet.total_tva, cdet.total_ttc, ';
372 $sql .= ' pr.rowid as product_rowid, pr.ref as product_ref, pr.label as product_label, pr.barcode as product_barcode, pr.tobatch as product_batch, pr.tosell as product_status, pr.tobuy as product_status_buy';
373 
374 if (($search_categ_cus > 0) || ($search_categ_cus == -2)) {
375  $sql .= ", cc.fk_categorie, cc.fk_soc";
376 }
377 // Add fields from extrafields
378 if (!empty($extrafields->attributes[$object->table_element]['label'])) {
379  foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
380  $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : '');
381  }
382 }
383 // Add fields from hooks
384 $parameters = array();
385 $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook
386 $sql .= $hookmanager->resPrint;
387 $sql .= ' FROM '.MAIN_DB_PREFIX.'societe as s';
388 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays)";
389 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typent)";
390 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)";
391 if (($search_categ_cus > 0) || ($search_categ_cus == -2)) {
392  $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_societe as cc ON s.rowid = cc.fk_soc"; // We'll need this table joined to the select in order to filter by categ
393 }
394 
395 // Détail commande
396 $sql .= ', '.MAIN_DB_PREFIX.'commandedet as cdet';
397 $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'commande as c ON cdet.fk_commande=c.rowid';
398 $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as pr ON pr.rowid=cdet.fk_product';
399 
400 if (!empty($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
401  $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."commande_extrafields as ef on (c.rowid = ef.fk_object)";
402 }
403 if ($sall || $search_product_category > 0) {
404  $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'commandedet as pd ON c.rowid=pd.fk_commande';
405 }
406 if ($search_product_category > 0) {
407  $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product=pd.fk_product';
408 }
409 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = c.fk_projet";
410 $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'user as u ON c.fk_user_author = u.rowid';
411 
412 // We'll need this table joined to the select in order to filter by sale
413 if ($search_sale > 0 || (empty($user->rights->societe->client->voir) && !$socid)) {
414  $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
415 }
416 if ($search_user > 0) {
417  $sql .= ", ".MAIN_DB_PREFIX."element_contact as ec";
418  $sql .= ", ".MAIN_DB_PREFIX."c_type_contact as tc";
419 }
420 
421 // Add table from hooks
422 $parameters = array();
423 $reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object); // Note that $action and $object may have been modified by hook
424 $sql .= $hookmanager->resPrint;
425 
426 $sql .= ' WHERE c.fk_soc = s.rowid';
427 $sql .= ' AND c.entity IN ('.getEntity('commande').')';
428 $sql .= ' AND cdet.product_type <> 9';
429 
430 if (!empty($productobuy)) {
431  $sql .= " AND pr.tobuy = 1";
432 }
433 if (!empty($productonly)) {
434  $sql .= " AND (cdet.product_type = 0 OR cdet.product_type = 1)";
435 }
436 if (!empty($disablelinefree)) {
437  $sql .= " AND cdet.fk_product IS NOT NULL";
438 }
439 if ($search_product_category > 0) {
440  $sql .= " AND cp.fk_categorie = ".((int) $search_product_category);
441 }
442 if ($socid > 0) {
443  $sql .= ' AND s.rowid = '.((int) $socid);
444 }
445 if (empty($user->rights->societe->client->voir) && !$socid) {
446  $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
447 }
448 if ($search_refProduct) {
449  $sql .= natural_search('pr.ref', $search_refProduct);
450 }
451 if ($search_descProduct) {
452  $sql .= natural_search('pr.label', $search_descProduct);
453  $sql .= natural_search('cdet.description', $search_descProduct);
454 }
455 if ($search_ref) {
456  $sql .= natural_search('c.ref', $search_ref);
457 }
458 if ($search_ref_customer) {
459  $sql .= natural_search('c.ref_client', $search_ref_customer);
460 }
461 if ($sall) {
462  $sql .= natural_search(array_keys($fieldstosearchall), $sall);
463 }
464 if ($search_billed != '' && $search_billed >= 0) {
465  $sql .= ' AND c.facture = '.((int) $search_billed);
466 }
467 if ($search_status <> '') {
468  if ($search_status <= 3 && $search_status >= -1) { // status from -1 to 3 are real status (other are virtual combination)
469  if ($search_status == 1 && !isModEnabled('expedition')) {
470  $sql .= ' AND c.fk_statut IN (1,2)'; // If module expedition disabled, we include order with status 'sending in process' into 'validated'
471  } else {
472  $sql .= ' AND c.fk_statut = '.((int) $search_status); // brouillon, validee, en cours, annulee
473  }
474  }
475  if ($search_status == -2) { // To process
476  //$sql.= ' AND c.fk_statut IN (1,2,3) AND c.facture = 0';
477  $sql .= " AND ((c.fk_statut IN (1,2)) OR (c.fk_statut = 3 AND c.facture = 0))"; // If status is 2 and facture=1, it must be selected
478  }
479  if ($search_status == -3) { // To bill
480  //$sql.= ' AND c.fk_statut in (1,2,3)';
481  //$sql.= ' AND c.facture = 0'; // invoice not created
482  $sql .= ' AND ((c.fk_statut IN (1,2)) OR (c.fk_statut = 3 AND c.facture = 0))'; // validated, in process or closed but not billed
483  }
484  if ($search_status == -4) { // "validate and in progress"
485  $sql .= ' AND (c.fk_statut IN (1,2))'; // validated, in process
486  }
487 }
488 
489 if ($search_datecloture_start) {
490  $sql .= " AND c.date_cloture >= '".$db->idate($search_datecloture_start)."'";
491 }
492 if ($search_datecloture_end) {
493  $sql .= " AND c.date_cloture <= '".$db->idate($search_datecloture_end)."'";
494 }
495 if ($search_dateorder_start) {
496  $sql .= " AND c.date_commande >= '".$db->idate($search_dateorder_start)."'";
497 }
498 if ($search_dateorder_end) {
499  $sql .= " AND c.date_commande <= '".$db->idate($search_dateorder_end)."'";
500 }
501 if ($search_datedelivery_start) {
502  $sql .= " AND c.date_livraison >= '".$db->idate($search_datedelivery_start)."'";
503 }
504 if ($search_datedelivery_end) {
505  $sql .= " AND c.date_livraison <= '".$db->idate($search_datedelivery_end)."'";
506 }
507 if ($search_town) {
508  $sql .= natural_search('s.town', $search_town);
509 }
510 if ($search_zip) {
511  $sql .= natural_search("s.zip", $search_zip);
512 }
513 if ($search_state) {
514  $sql .= natural_search("state.nom", $search_state);
515 }
516 if ($search_country) {
517  $sql .= " AND s.fk_pays IN (".$db->sanitize($search_country).')';
518 }
519 if ($search_type_thirdparty && $search_type_thirdparty != '-1') {
520  $sql .= " AND s.fk_typent IN (".$db->sanitize($search_type_thirdparty).')';
521 }
522 if ($search_company) {
523  $sql .= natural_search('s.nom', $search_company);
524 }
525 if ($search_company_alias) {
526  $sql .= natural_search('s.name_alias', $search_company_alias);
527 }
528 if ($search_sale > 0) {
529  $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $search_sale);
530 }
531 if ($search_user > 0) {
532  $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);
533 }
534 if ($search_total_ht != '') {
535  $sql .= natural_search('cdet.total_ht', $search_total_ht, 1);
536 }
537 if ($search_total_vat != '') {
538  $sql .= natural_search('cdet.total_tva', $search_total_vat, 1);
539 }
540 if ($search_total_ttc != '') {
541  $sql .= natural_search('cdet.total_ttc', $search_total_ttc, 1);
542 }
543 if ($search_warehouse != '' && $search_warehouse > 0) {
544  $sql .= natural_search('c.fk_warehouse', $search_warehouse, 1);
545 }
546 if ($search_multicurrency_code != '') {
547  $sql .= " AND c.multicurrency_code = '".$db->escape($search_multicurrency_code)."'";
548 }
549 if ($search_multicurrency_tx != '') {
550  $sql .= natural_search('c.multicurrency_tx', $search_multicurrency_tx, 1);
551 }
552 if ($search_multicurrency_montant_ht != '') {
553  $sql .= natural_search('c.multicurrency_total_ht', $search_multicurrency_montant_ht, 1);
554 }
555 if ($search_multicurrency_montant_vat != '') {
556  $sql .= natural_search('c.multicurrency_total_tva', $search_multicurrency_montant_vat, 1);
557 }
558 if ($search_multicurrency_montant_ttc != '') {
559  $sql .= natural_search('c.multicurrency_total_ttc', $search_multicurrency_montant_ttc, 1);
560 }
561 if ($search_login) {
562  $sql .= natural_search(array("u.login", "u.firstname", "u.lastname"), $search_login);
563 }
564 if ($search_project_ref != '') {
565  $sql .= natural_search("p.ref", $search_project_ref);
566 }
567 if ($search_project != '') {
568  $sql .= natural_search("p.title", $search_project);
569 }
570 if ($search_categ_cus > 0) {
571  $sql .= " AND cc.fk_categorie = ".((int) $search_categ_cus);
572 }
573 if ($search_categ_cus == -2) {
574  $sql .= " AND cc.fk_categorie IS NULL";
575 }
576 if ($search_fk_cond_reglement > 0) {
577  $sql .= " AND c.fk_cond_reglement = ".((int) $search_fk_cond_reglement);
578 }
579 if ($search_fk_shipping_method > 0) {
580  $sql .= " AND c.fk_shipping_method = ".((int) $search_fk_shipping_method);
581 }
582 if ($search_fk_mode_reglement > 0) {
583  $sql .= " AND c.fk_mode_reglement = ".((int) $search_fk_mode_reglement);
584 }
585 if ($search_fk_input_reason > 0) {
586  $sql .= " AND c.fk_input_reason = ".((int) $search_fk_input_reason);
587 }
588 
589 // Add where from extra fields
590 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
591 // Add where from hooks
592 $parameters = array();
593 $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook
594 $sql .= $hookmanager->resPrint;
595 
596 // Add HAVING from hooks
597 $parameters = array();
598 $reshook = $hookmanager->executeHooks('printFieldListHaving', $parameters, $object); // Note that $action and $object may have been modified by hook
599 $sql .= empty($hookmanager->resPrint) ? "" : " HAVING 1=1 ".$hookmanager->resPrint;
600 
601 $sql .= $db->order($sortfield, $sortorder);
602 
603 // Count total nb of records
604 $nbtotalofrecords = '';
605 if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
606  $result = $db->query($sql);
607  $nbtotalofrecords = $db->num_rows($result);
608 
609  if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
610  $page = 0;
611  $offset = 0;
612  }
613 }
614 
615 $sql .= $db->plimit($limit + 1, $offset);
616 //print $sql;
617 
618 $resql = $db->query($sql);
619 if ($resql) {
620  if ($socid > 0) {
621  $soc = new Societe($db);
622  $soc->fetch($socid);
623  $title = $langs->trans('ListOrderLigne').' - '.$soc->name;
624  if (empty($search_company)) {
625  $search_company = $soc->name;
626  }
627  } else {
628  $title = $langs->trans('ListOrderLigne');
629  }
630  if (strval($search_status) == '0') {
631  $title .= ' - '.$langs->trans('StatusOrderDraftShort');
632  }
633  if ($search_status == 1) {
634  $title .= ' - '.$langs->trans('StatusOrderValidatedShort');
635  }
636  if ($search_status == 2) {
637  $title .= ' - '.$langs->trans('StatusOrderSentShort');
638  }
639  if ($search_status == 3) {
640  $title .= ' - '.$langs->trans('StatusOrderToBillShort');
641  }
642  if ($search_status == -1) {
643  $title .= ' - '.$langs->trans('StatusOrderCanceledShort');
644  }
645  if ($search_status == -2) {
646  $title .= ' - '.$langs->trans('StatusOrderToProcessShort');
647  }
648  if ($search_status == -3) {
649  $title .= ' - '.$langs->trans('StatusOrderValidated').', '.(!isModEnabled('expedition') ? '' : $langs->trans("StatusOrderSent").', ').$langs->trans('StatusOrderToBill');
650  }
651  if ($search_status == -4) {
652  $title .= ' - '.$langs->trans("StatusOrderValidatedShort").'+'.$langs->trans("StatusOrderSentShort");
653  }
654 
655  $num = $db->num_rows($resql);
656 
657  $arrayofselected = is_array($toselect) ? $toselect : array();
658 
659  if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $sall) {
660  $obj = $db->fetch_object($resql);
661  $id = $obj->rowid;
662  header("Location: ".DOL_URL_ROOT.'/commande/card.php?id='.$id);
663  exit;
664  }
665 
666  llxHeader('', $title, $help_url);
667 
668  $param = '';
669 
670  if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
671  $param .= '&contextpage='.urlencode($contextpage);
672  }
673  if ($limit > 0 && $limit != $conf->liste_limit) {
674  $param .= '&limit='.((int) $limit);
675  }
676  if ($sall) {
677  $param .= '&sall='.urlencode($sall);
678  }
679  if ($socid > 0) {
680  $param .= '&socid='.urlencode($socid);
681  }
682  if ($search_status != '') {
683  $param .= '&search_status='.urlencode($search_status);
684  }
685  if ($search_datecloture_start) {
686  $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');
687  }
688  if ($search_datecloture_end) {
689  $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');
690  }
691  if ($search_dateorder_start) {
692  $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');
693  }
694  if ($search_dateorder_end) {
695  $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');
696  }
697  if ($search_datedelivery_start) {
698  $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');
699  }
700  if ($search_datedelivery_end) {
701  $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');
702  }
703  if ($search_ref) {
704  $param .= '&search_ref='.urlencode($search_ref);
705  }
706  if ($search_company) {
707  $param .= '&search_company='.urlencode($search_company);
708  }
709  if ($search_company_alias) {
710  $param .= '&search_company_alias='.urlencode($search_company_alias);
711  }
712  if ($search_ref_customer) {
713  $param .= '&search_ref_customer='.urlencode($search_ref_customer);
714  }
715  if ($search_user > 0) {
716  $param .= '&search_user='.urlencode($search_user);
717  }
718  if ($search_sale > 0) {
719  $param .= '&search_sale='.urlencode($search_sale);
720  }
721  if ($search_total_ht != '') {
722  $param .= '&search_total_ht='.urlencode($search_total_ht);
723  }
724  if ($search_total_vat != '') {
725  $param .= '&search_total_vat='.urlencode($search_total_vat);
726  }
727  if ($search_total_ttc != '') {
728  $param .= '&search_total_ttc='.urlencode($search_total_ttc);
729  }
730  if ($search_warehouse != '') {
731  $param .= '&search_warehouse='.urlencode($search_warehouse);
732  }
733  if ($search_login) {
734  $param .= '&search_login='.urlencode($search_login);
735  }
736  if ($search_multicurrency_code != '') {
737  $param .= '&search_multicurrency_code='.urlencode($search_multicurrency_code);
738  }
739  if ($search_multicurrency_tx != '') {
740  $param .= '&search_multicurrency_tx='.urlencode($search_multicurrency_tx);
741  }
742  if ($search_multicurrency_montant_ht != '') {
743  $param .= '&search_multicurrency_montant_ht='.urlencode($search_multicurrency_montant_ht);
744  }
745  if ($search_multicurrency_montant_vat != '') {
746  $param .= '&search_multicurrency_montant_vat='.urlencode($search_multicurrency_montant_vat);
747  }
748  if ($search_multicurrency_montant_ttc != '') {
749  $param .= '&search_multicurrency_montant_ttc='.urlencode($search_multicurrency_montant_ttc);
750  }
751  if ($search_project_ref >= 0) {
752  $param .= "&search_project_ref=".urlencode($search_project_ref);
753  }
754  if ($search_town != '') {
755  $param .= '&search_town='.urlencode($search_town);
756  }
757  if ($search_zip != '') {
758  $param .= '&search_zip='.urlencode($search_zip);
759  }
760  if ($search_state != '') {
761  $param .= '&search_state='.urlencode($search_state);
762  }
763  if ($search_country != '') {
764  $param .= '&search_country='.urlencode($search_country);
765  }
766  if ($search_type_thirdparty && $search_type_thirdparty != '-1') {
767  $param .= '&search_type_thirdparty='.urlencode($search_type_thirdparty);
768  }
769  if ($search_product_category != '') {
770  $param .= '&search_product_category='.urlencode($search_product_category);
771  }
772  if (($search_categ_cus > 0) || ($search_categ_cus == -2)) {
773  $param .= '&search_categ_cus='.urlencode($search_categ_cus);
774  }
775  if ($show_files) {
776  $param .= '&show_files='.urlencode($show_files);
777  }
778  if ($optioncss != '') {
779  $param .= '&optioncss='.urlencode($optioncss);
780  }
781  if ($search_billed != '') {
782  $param .= '&search_billed='.urlencode($search_billed);
783  }
784  if ($search_fk_cond_reglement > 0) {
785  $param .= '&search_fk_cond_reglement='.urlencode($search_fk_cond_reglement);
786  }
787  if ($search_fk_shipping_method > 0) {
788  $param .= '&search_fk_shipping_method='.urlencode($search_fk_shipping_method);
789  }
790  if ($search_fk_mode_reglement > 0) {
791  $param .= '&search_fk_mode_reglement='.urlencode($search_fk_mode_reglement);
792  }
793  if ($search_fk_input_reason > 0) {
794  $param .= '&search_fk_input_reason='.urlencode($search_fk_input_reason);
795  }
796  if (!empty($productobuy)) {
797  $param .= '&productobuy='.urlencode($productobuy);
798  }
799  if (!empty($productonly)) {
800  $param .= '&productonly='.urlencode($productonly);
801  }
802  if (!empty($disablelinefree)) {
803  $param .= '&disablelinefree='.urlencode($disablelinefree);
804  }
805 
806  // Add $param from extra fields
807  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
808 
809  // Add $param from hooks
810  $parameters = array();
811  $reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object); // Note that $action and $object may have been modified by hook
812  $param .= $hookmanager->resPrint;
813 
814  // List of mass actions available
815  $arrayofmassactions = array(
816  // TODO add mass action here
817  );
818  $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
819 
820  $url = DOL_URL_ROOT.'/commande/card.php?action=create';
821  if (!empty($socid)) {
822  $url .= '&socid='.$socid;
823  }
824  $newcardbutton = '';//dolGetButtonTitle($langs->trans('NewOrder'), '', 'fa fa-plus-circle', $url, '', $contextpage == 'orderlistdet' && $permissiontoadd);
825 
826  // Lines of title fields
827  print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
828  if ($optioncss != '') {
829  print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
830  }
831  print '<input type="hidden" name="token" value="'.newToken().'">';
832  print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
833  print '<input type="hidden" name="action" value="list">';
834  print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
835  print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
836  print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
837  print '<input type="hidden" name="search_status" value="'.$search_status.'">';
838  print '<input type="hidden" name="socid" value="'.$socid.'">';
839 
840  print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'order', 0, $newcardbutton, '', $limit, 0, 0, 1);
841 
842  $topicmail = "SendOrderRef";
843  $modelmail = "order_send";
844  $objecttmp = new Commande($db);
845  $trackid = 'ord'.$object->id;
846  include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
847 
848  if ($sall) {
849  foreach ($fieldstosearchall as $key => $val) {
850  $fieldstosearchall[$key] = $langs->trans($val);
851  }
852  print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'</div>';
853  }
854 
855  $moreforfilter = '';
856 
857  $moreforfilter .= '<input type="checkbox" name="productobuy"'.(!empty($productobuy)?'value="productobuychecked" checked':'' ).'><label for="productobuy">'.$langs->trans("productobuy").'</label>';
858  $moreforfilter .= '<input type="checkbox" name="productonly"'.(!empty($productonly)?'value="productonlychecked" checked':'' ).'><label for="productonly">'.$langs->trans("productonly").'</label>';
859  $moreforfilter .= '<input type="checkbox" name="disablelinefree"'.(!empty($disablelinefree)?'value="disablelinefreechecked" checked':'' ).'><label for="disablelinefree">'.$langs->trans("disablelinefree").'</label>';
860  $moreforfilter .= '<br>';
861 
862  // If the user can view prospects other than his'
863  if ($user->rights->user->user->lire) {
864  $langs->load("commercial");
865  $moreforfilter .= '<div class="divsearchfield">';
866  $tmptitle = $langs->trans('ThirdPartiesOfSaleRepresentative');
867  $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, $tmptitle, 'maxwidth250 widthcentpercentminusx');
868  $moreforfilter .= '</div>';
869  }
870  // If the user can view other users
871  if ($user->rights->user->user->lire) {
872  $moreforfilter .= '<div class="divsearchfield">';
873  $tmptitle = $langs->trans('LinkedToSpecificUsers');
874  $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$form->select_dolusers($search_user, 'search_user', $tmptitle, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth250 widthcentpercentminusx');
875  $moreforfilter .= '</div>';
876  }
877  // If the user can view prospects other than his'
878  if (isModEnabled("categorie") && $user->hasRight('categorie', 'lire') && ($user->hasRight('produit', 'lire') || $user->hasRight('service', 'lire'))) {
879  include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
880  $moreforfilter .= '<div class="divsearchfield">';
881  $tmptitle = $langs->trans('IncludingProductWithTag');
882  $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, null, 'parent', null, null, 1);
883  $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);
884  $moreforfilter .= '</div>';
885  }
886  if (isModEnabled("categorie") && $user->hasRight('categorie', 'lire')) {
887  require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
888  $moreforfilter .= '<div class="divsearchfield">';
889  $tmptitle = $langs->trans('CustomersProspectsCategoriesShort');
890  $moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"').$formother->select_categories('customer', $search_categ_cus, 'search_categ_cus', 1, $tmptitle, 'maxwidth300 widthcentpercentminusx');
891  $moreforfilter .= '</div>';
892  }
893  if (isModEnabled('stock') && !empty($conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER)) {
894  require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
895  $formproduct = new FormProduct($db);
896  $moreforfilter .= '<div class="divsearchfield">';
897  $tmptitle = $langs->trans('Warehouse');
898  $moreforfilter .= img_picto($tmptitle, 'stock', 'class="pictofixedwidth"').$formproduct->selectWarehouses($search_warehouse, 'search_warehouse', '', 1, 0, 0, $tmptitle, 0, 0, array(), 'maxwidth250 widthcentpercentminusx');
899  $moreforfilter .= '</div>';
900  }
901 
902 
903  $parameters = array();
904  $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook
905  if (empty($reshook)) {
906  $moreforfilter .= $hookmanager->resPrint;
907  } else {
908  $moreforfilter = $hookmanager->resPrint;
909  }
910 
911  if (!empty($moreforfilter)) {
912  print '<div class="liste_titre liste_titre_bydiv centpercent">';
913  print $moreforfilter;
914  print '</div>';
915  }
916 
917  $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
918  $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN', '')); // This also change content of $arrayfields
919  $selectedfields .= $form->showCheckAddButtons('checkforselect', 1);
920 
921  if (GETPOST('autoselectall', 'int')) {
922  $selectedfields .= '<script>';
923  $selectedfields .= ' $(document).ready(function() {';
924  $selectedfields .= ' console.log("Autoclick on checkforselects");';
925  $selectedfields .= ' $("#checkforselects").click();';
926  $selectedfields .= ' $("#massaction").val("createbills").change();';
927  $selectedfields .= ' });';
928  $selectedfields .= '</script>';
929  }
930 
931  print '<div class="div-table-responsive">';
932  print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
933 
934  print '<tr class="liste_titre_filter">';
935 
936  // Action column
937  if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
938  print '<td class="liste_titre" align="middle">';
939  $searchpicto = $form->showFilterButtons('left');
940  print $searchpicto;
941  print '</td>';
942  }
943 
944  // Détail commande
945  if (!empty($arrayfields['pr.ref']['checked'])) {
946  print '<td class="liste_titre">';
947  print '<input class="flat" size="6" type="text" name="search_refProduct" value="'.dol_escape_htmltag($search_refProduct).'">';
948  print '</td>';
949  }
950  // Product Description
951  if (!empty($arrayfields['pr.desc']['checked'])) {
952  print '<td class="liste_titre">';
953  print '<input class="flat" size="6" type="text" name="search_descProduct" value="'.dol_escape_htmltag($search_descProduct).'">';
954  print '</td>';
955  }
956  // Product QtyOrdered
957  if (!empty($arrayfields['cdet.qty']['checked'])) {
958  print '<td class="liste_titre"></td>';
959  }
960 
961  // Ref
962  if (!empty($arrayfields['c.ref']['checked'])) {
963  print '<td class="liste_titre">';
964  print '<input class="flat" size="6" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
965  print '</td>';
966  }
967  // Ref customer
968  if (!empty($arrayfields['c.ref_client']['checked'])) {
969  print '<td class="liste_titre" align="left">';
970  print '<input class="flat" type="text" size="6" name="search_ref_customer" value="'.dol_escape_htmltag($search_ref_customer).'">';
971  print '</td>';
972  }
973  // Project ref
974  if (!empty($arrayfields['p.ref']['checked'])) {
975  print '<td class="liste_titre"><input type="text" class="flat" size="6" name="search_project_ref" value="'.dol_escape_htmltag($search_project_ref).'"></td>';
976  }
977  // Project title
978  if (!empty($arrayfields['p.title']['checked'])) {
979  print '<td class="liste_titre"><input type="text" class="flat" size="6" name="search_project" value="'.dol_escape_htmltag($search_project).'"></td>';
980  }
981  // Thirpdarty
982  if (!empty($arrayfields['s.nom']['checked'])) {
983  print '<td class="liste_titre" align="left">';
984  print '<input class="flat maxwidth100" type="text" name="search_company" value="'.dol_escape_htmltag($search_company).'">';
985  print '</td>';
986  }
987  // Alias
988  if (!empty($arrayfields['s.name_alias']['checked'])) {
989  print '<td class="liste_titre" align="left">';
990  print '<input class="flat maxwidth100" type="text" name="search_company_alias" value="'.dol_escape_htmltag($search_company_alias).'">';
991  print '</td>';
992  }
993  // Town
994  if (!empty($arrayfields['s.town']['checked'])) {
995  print '<td class="liste_titre"><input class="flat" type="text" size="4" name="search_town" value="'.dol_escape_htmltag($search_town).'"></td>';
996  }
997  // Zip
998  if (!empty($arrayfields['s.zip']['checked'])) {
999  print '<td class="liste_titre"><input class="flat" type="text" size="4" name="search_zip" value="'.dol_escape_htmltag($search_zip).'"></td>';
1000  }
1001  // State
1002  if (!empty($arrayfields['state.nom']['checked'])) {
1003  print '<td class="liste_titre">';
1004  print '<input class="flat" size="4" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).'">';
1005  print '</td>';
1006  }
1007  // Country
1008  if (!empty($arrayfields['country.code_iso']['checked'])) {
1009  print '<td class="liste_titre" align="center">';
1010  print $form->select_country($search_country, 'search_country', '', 0, 'minwidth100imp maxwidth100');
1011  print '</td>';
1012  }
1013  // Company type
1014  if (!empty($arrayfields['typent.code']['checked'])) {
1015  print '<td class="liste_titre maxwidthonsmartphone" align="center">';
1016  print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 1, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT), '', 1);
1017  print '</td>';
1018  }
1019  // Date order
1020  if (!empty($arrayfields['c.date_commande']['checked'])) {
1021  print '<td class="liste_titre center">';
1022  print '<div class="nowrap">';
1023  print $form->selectDate($search_dateorder_start ? $search_dateorder_start : -1, 'search_dateorder_start_', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
1024  print '</div>';
1025  print '<div class="nowrap">';
1026  print $form->selectDate($search_dateorder_end ? $search_dateorder_end : -1, 'search_dateorder_end_', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
1027  print '</div>';
1028  print '</td>';
1029  }
1030  if (!empty($arrayfields['c.date_delivery']['checked'])) {
1031  print '<td class="liste_titre center">';
1032  print '<div class="nowrap">';
1033  print $form->selectDate($search_datedelivery_start ? $search_datedelivery_start : -1, 'search_datedelivery_start_', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
1034  print '</div>';
1035  print '<div class="nowrap">';
1036  print $form->selectDate($search_datedelivery_end ? $search_datedelivery_end : -1, 'search_datedelivery_end_', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
1037  print '</div>';
1038  print '</td>';
1039  }
1040  // Shipping Method
1041  if (!empty($arrayfields['c.fk_shipping_method']['checked'])) {
1042  print '<td class="liste_titre">';
1043  $form->selectShippingMethod($search_fk_shipping_method, 'search_fk_shipping_method', '', 1, '', 1);
1044  print '</td>';
1045  }
1046  // Payment term
1047  if (!empty($arrayfields['c.fk_cond_reglement']['checked'])) {
1048  print '<td class="liste_titre">';
1049  $form->select_conditions_paiements($search_fk_cond_reglement, 'search_fk_cond_reglement', 1, 1, 1);
1050  print '</td>';
1051  }
1052  // Payment mode
1053  if (!empty($arrayfields['c.fk_mode_reglement']['checked'])) {
1054  print '<td class="liste_titre">';
1055  $form->select_types_paiements($search_fk_mode_reglement, 'search_fk_mode_reglement', '', 0, 1, 1, 0, -1);
1056  print '</td>';
1057  }
1058  // Channel
1059  if (!empty($arrayfields['c.fk_input_reason']['checked'])) {
1060  print '<td class="liste_titre">';
1061  $form->selectInputReason($search_fk_input_reason, 'search_fk_input_reason', '', 1, '', 1);
1062  print '</td>';
1063  }
1064  if (!empty($arrayfields['cdet.total_ht']['checked'])) {
1065  // Amount
1066  print '<td class="liste_titre right">';
1067  print '<input class="flat" type="text" size="4" name="search_total_ht" value="'.dol_escape_htmltag($search_total_ht).'">';
1068  print '</td>';
1069  }
1070  if (!empty($arrayfields['c.total_vat']['checked'])) {
1071  // Amount
1072  print '<td class="liste_titre right">';
1073  print '<input class="flat" type="text" size="4" name="search_total_vat" value="'.dol_escape_htmltag($search_total_vat).'">';
1074  print '</td>';
1075  }
1076  if (!empty($arrayfields['cdet.total_ttc']['checked'])) {
1077  // Amount
1078  print '<td class="liste_titre right">';
1079  print '<input class="flat" type="text" size="5" name="search_total_ttc" value="'.$search_total_ttc.'">';
1080  print '</td>';
1081  }
1082  if (!empty($arrayfields['c.fk_warehouse']['checked'])) {
1083  // Warehouse
1084  print '<td class="liste_titre right"></td>';
1085  }
1086  if (!empty($arrayfields['c.multicurrency_code']['checked'])) {
1087  // Currency
1088  print '<td class="liste_titre">';
1089  print $form->selectMultiCurrency($search_multicurrency_code, 'search_multicurrency_code', 1);
1090  print '</td>';
1091  }
1092  if (!empty($arrayfields['c.multicurrency_tx']['checked'])) {
1093  // Currency rate
1094  print '<td class="liste_titre">';
1095  print '<input class="flat" type="text" size="4" name="search_multicurrency_tx" value="'.dol_escape_htmltag($search_multicurrency_tx).'">';
1096  print '</td>';
1097  }
1098  if (!empty($arrayfields['c.multicurrency_total_ht']['checked'])) {
1099  // Amount
1100  print '<td class="liste_titre right">';
1101  print '<input class="flat" type="text" size="4" name="search_multicurrency_montant_ht" value="'.dol_escape_htmltag($search_multicurrency_montant_ht).'">';
1102  print '</td>';
1103  }
1104  if (!empty($arrayfields['c.multicurrency_total_vat']['checked'])) {
1105  // Amount VAT
1106  print '<td class="liste_titre right">';
1107  print '<input class="flat" type="text" size="4" name="search_multicurrency_montant_vat" value="'.dol_escape_htmltag($search_multicurrency_montant_vat).'">';
1108  print '</td>';
1109  }
1110  if (!empty($arrayfields['c.multicurrency_total_ttc']['checked'])) {
1111  // Amount
1112  print '<td class="liste_titre right">';
1113  print '<input class="flat" type="text" size="4" name="search_multicurrency_montant_ttc" value="'.dol_escape_htmltag($search_multicurrency_montant_ttc).'">';
1114  print '</td>';
1115  }
1116  if (!empty($arrayfields['u.login']['checked'])) {
1117  // Author
1118  print '<td class="liste_titre" align="center">';
1119  print '<input class="flat" size="4" type="text" name="search_login" value="'.dol_escape_htmltag($search_login).'">';
1120  print '</td>';
1121  }
1122  if (!empty($arrayfields['sale_representative']['checked'])) {
1123  print '<td class="liste_titre"></td>';
1124  }
1125  if (!empty($arrayfields['total_pa']['checked'])) {
1126  print '<td class="liste_titre right">';
1127  print '</td>';
1128  }
1129  if (!empty($arrayfields['total_margin']['checked'])) {
1130  print '<td class="liste_titre right">';
1131  print '</td>';
1132  }
1133  if (!empty($arrayfields['total_margin_rate']['checked'])) {
1134  print '<td class="liste_titre right">';
1135  print '</td>';
1136  }
1137  if (!empty($arrayfields['total_mark_rate']['checked'])) {
1138  print '<td class="liste_titre right">';
1139  print '</td>';
1140  }
1141  // Extra fields
1142  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
1143  // Fields from hook
1144  $parameters = array('arrayfields'=>$arrayfields);
1145  $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
1146  print $hookmanager->resPrint;
1147  // Date creation
1148  if (!empty($arrayfields['c.datec']['checked'])) {
1149  print '<td class="liste_titre">';
1150  print '</td>';
1151  }
1152  // Date modification
1153  if (!empty($arrayfields['c.tms']['checked'])) {
1154  print '<td class="liste_titre">';
1155  print '</td>';
1156  }
1157  // Date cloture
1158  if (!empty($arrayfields['c.date_cloture']['checked'])) {
1159  print '<td class="liste_titre center">';
1160  print '<div class="nowrap">';
1161  print $form->selectDate($search_datecloture_start ? $search_datecloture_start : -1, 'search_datecloture_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
1162  print '</div>';
1163  print '<div class="nowrap">';
1164  print $form->selectDate($search_datecloture_end ? $search_datecloture_end : -1, 'search_datecloture_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
1165  print '</div>';
1166  print '</td>';
1167  }
1168  // Note public
1169  if (!empty($arrayfields['c.note_public']['checked'])) {
1170  print '<td class="liste_titre">';
1171  print '</td>';
1172  }
1173  // Note private
1174  if (!empty($arrayfields['c.note_private']['checked'])) {
1175  print '<td class="liste_titre">';
1176  print '</td>';
1177  }
1178  // Shippable
1179  if (!empty($arrayfields['shippable']['checked'])) {
1180  print '<td class="liste_titre maxwidthonsmartphone" align="center">';
1181  //print $form->selectyesno('search_shippable', $search_shippable, 1, 0, 1, 1);
1182  if (!empty($conf->global->ORDER_SHIPABLE_STATUS_DISABLED_BY_DEFAULT)) {
1183  print '<input type="checkbox" name="show_shippable_command" value="1"'.($show_shippable_command ? ' checked' : '').'>';
1184  print $langs->trans('ShowShippableStatus');
1185  } else {
1186  $show_shippable_command = 1;
1187  }
1188  print '</td>';
1189  }
1190  // Status billed
1191  if (!empty($arrayfields['c.facture']['checked'])) {
1192  print '<td class="liste_titre maxwidthonsmartphone" align="center">';
1193  print $form->selectyesno('search_billed', $search_billed, 1, 0, 1, 1);
1194  print '</td>';
1195  }
1196  // Import key
1197  if (!empty($arrayfields['c.import_key']['checked'])) {
1198  print '<td class="liste_titre maxwidthonsmartphone" align="center">';
1199  print '</td>';
1200  }
1201  // Status
1202  if (!empty($arrayfields['c.fk_statut']['checked'])) {
1203  print '<td class="liste_titre maxwidthonsmartphone center">';
1204  $liststatus = array(
1205  Commande::STATUS_DRAFT=>$langs->trans("StatusOrderDraftShort"),
1206  Commande::STATUS_VALIDATED=>$langs->trans("StatusOrderValidated"),
1207  Commande::STATUS_SHIPMENTONPROCESS=>$langs->trans("StatusOrderSentShort"),
1208  Commande::STATUS_CLOSED=>$langs->trans("StatusOrderDelivered"),
1209  -3=>$langs->trans("StatusOrderValidatedShort").'+'.$langs->trans("StatusOrderSentShort").'+'.$langs->trans("StatusOrderDelivered"),
1210  -2=>$langs->trans("StatusOrderValidatedShort").'+'.$langs->trans("StatusOrderSentShort"),
1211  Commande::STATUS_CANCELED=>$langs->trans("StatusOrderCanceledShort")
1212  );
1213  print $form->selectarray('search_status', $liststatus, $search_status, -5, 0, 0, '', 0, 0, 0, '', 'maxwidth125', 1);
1214  print '</td>';
1215  }
1216  // Action column
1217  if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
1218  print '<td class="liste_titre" align="middle">';
1219  $searchpicto = $form->showFilterButtons();
1220  print $searchpicto;
1221  print '</td>';
1222  }
1223  print "</tr>\n";
1224 
1225  // Fields title
1226  print '<tr class="liste_titre">';
1227 
1228  if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
1229  print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'maxwidthsearch center ');
1230  }
1231 
1232  // Détail commande
1233  if (!empty($arrayfields['pr.ref']['checked'])) {
1234  print_liste_field_titre($arrayfields['pr.ref']['label'], $_SERVER["PHP_SELF"], 'pr.ref', '', $param, '', $sortfield, $sortorder);
1235  }
1236  if (!empty($arrayfields['pr.desc']['checked'])) {
1237  print_liste_field_titre($arrayfields['pr.desc']['label'], $_SERVER["PHP_SELF"], 'pr.desc', '', $param, '', $sortfield, $sortorder);
1238  }
1239  if (!empty($arrayfields['cdet.qty']['checked'])) {
1240  print_liste_field_titre($arrayfields['cdet.qty']['label'], $_SERVER["PHP_SELF"], 'cdet.qty', '', $param, '', $sortfield, $sortorder);
1241  }
1242 
1243  if (!empty($arrayfields['c.ref']['checked'])) {
1244  print_liste_field_titre($arrayfields['c.ref']['label'], $_SERVER["PHP_SELF"], 'c.ref', '', $param, '', $sortfield, $sortorder);
1245  }
1246  if (!empty($arrayfields['c.ref_client']['checked'])) {
1247  print_liste_field_titre($arrayfields['c.ref_client']['label'], $_SERVER["PHP_SELF"], 'c.ref_client', '', $param, '', $sortfield, $sortorder);
1248  }
1249  if (!empty($arrayfields['p.ref']['checked'])) {
1250  print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], "p.ref", "", $param, '', $sortfield, $sortorder);
1251  }
1252  if (!empty($arrayfields['p.title']['checked'])) {
1253  print_liste_field_titre($arrayfields['p.title']['label'], $_SERVER["PHP_SELF"], "p.title", "", $param, '', $sortfield, $sortorder);
1254  }
1255  if (!empty($arrayfields['s.nom']['checked'])) {
1256  print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], 's.nom', '', $param, '', $sortfield, $sortorder);
1257  }
1258  if (!empty($arrayfields['s.name_alias']['checked'])) {
1259  print_liste_field_titre($arrayfields['s.name_alias']['label'], $_SERVER["PHP_SELF"], 's.name_alias', '', $param, '', $sortfield, $sortorder);
1260  }
1261  if (!empty($arrayfields['s.town']['checked'])) {
1262  print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], 's.town', '', $param, '', $sortfield, $sortorder);
1263  }
1264  if (!empty($arrayfields['s.zip']['checked'])) {
1265  print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], 's.zip', '', $param, '', $sortfield, $sortorder);
1266  }
1267  if (!empty($arrayfields['state.nom']['checked'])) {
1268  print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder);
1269  }
1270  if (!empty($arrayfields['country.code_iso']['checked'])) {
1271  print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, '', $sortfield, $sortorder, 'center ');
1272  }
1273  if (!empty($arrayfields['typent.code']['checked'])) {
1274  print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, '', $sortfield, $sortorder, 'center ');
1275  }
1276  if (!empty($arrayfields['c.date_commande']['checked'])) {
1277  print_liste_field_titre($arrayfields['c.date_commande']['label'], $_SERVER["PHP_SELF"], 'c.date_commande', '', $param, '', $sortfield, $sortorder, 'center ');
1278  }
1279  if (!empty($arrayfields['c.date_delivery']['checked'])) {
1280  print_liste_field_titre($arrayfields['c.date_delivery']['label'], $_SERVER["PHP_SELF"], 'c.date_livraison', '', $param, '', $sortfield, $sortorder, 'center ');
1281  }
1282  if (!empty($arrayfields['c.fk_shipping_method']['checked'])) {
1283  print_liste_field_titre($arrayfields['c.fk_shipping_method']['label'], $_SERVER["PHP_SELF"], "c.fk_shipping_method", "", $param, '', $sortfield, $sortorder);
1284  }
1285  if (!empty($arrayfields['c.fk_cond_reglement']['checked'])) {
1286  print_liste_field_titre($arrayfields['c.fk_cond_reglement']['label'], $_SERVER["PHP_SELF"], "c.fk_cond_reglement", "", $param, '', $sortfield, $sortorder);
1287  }
1288  if (!empty($arrayfields['c.fk_mode_reglement']['checked'])) {
1289  print_liste_field_titre($arrayfields['c.fk_mode_reglement']['label'], $_SERVER["PHP_SELF"], "c.fk_mode_reglement", "", $param, '', $sortfield, $sortorder);
1290  }
1291  if (!empty($arrayfields['c.fk_input_reason']['checked'])) {
1292  print_liste_field_titre($arrayfields['c.fk_input_reason']['label'], $_SERVER["PHP_SELF"], "c.fk_input_reason", "", $param, '', $sortfield, $sortorder);
1293  }
1294  if (!empty($arrayfields['cdet.total_ht']['checked'])) {
1295  print_liste_field_titre($arrayfields['cdet.total_ht']['label'], $_SERVER["PHP_SELF"], 'cdet.total_ht', '', $param, '', $sortfield, $sortorder, 'right ');
1296  }
1297  if (!empty($arrayfields['c.total_vat']['checked'])) {
1298  print_liste_field_titre($arrayfields['c.total_vat']['label'], $_SERVER["PHP_SELF"], 'cdet.total_tva', '', $param, '', $sortfield, $sortorder, 'right ');
1299  }
1300  if (!empty($arrayfields['cdet.total_ttc']['checked'])) {
1301  print_liste_field_titre($arrayfields['cdet.total_ttc']['label'], $_SERVER["PHP_SELF"], 'cdet.total_ttc', '', $param, '', $sortfield, $sortorder, 'right ');
1302  }
1303  if (!empty($arrayfields['c.fk_warehouse']['checked'])) {
1304  print_liste_field_titre($arrayfields['c.fk_warehouse']['label'], "", '', '', $param, '', $sortfield, $sortorder);
1305  }
1306  if (!empty($arrayfields['c.multicurrency_code']['checked'])) {
1307  print_liste_field_titre($arrayfields['c.multicurrency_code']['label'], $_SERVER['PHP_SELF'], 'c.multicurrency_code', '', $param, '', $sortfield, $sortorder);
1308  }
1309  if (!empty($arrayfields['c.multicurrency_tx']['checked'])) {
1310  print_liste_field_titre($arrayfields['c.multicurrency_tx']['label'], $_SERVER['PHP_SELF'], 'c.multicurrency_tx', '', $param, '', $sortfield, $sortorder);
1311  }
1312  if (!empty($arrayfields['c.multicurrency_total_ht']['checked'])) {
1313  print_liste_field_titre($arrayfields['c.multicurrency_total_ht']['label'], $_SERVER['PHP_SELF'], 'c.multicurrency_total_ht', '', $param, 'class="right"', $sortfield, $sortorder);
1314  }
1315  if (!empty($arrayfields['c.multicurrency_total_vat']['checked'])) {
1316  print_liste_field_titre($arrayfields['c.multicurrency_total_vat']['label'], $_SERVER['PHP_SELF'], 'c.multicurrency_total_tva', '', $param, 'class="right"', $sortfield, $sortorder);
1317  }
1318  if (!empty($arrayfields['c.multicurrency_total_ttc']['checked'])) {
1319  print_liste_field_titre($arrayfields['c.multicurrency_total_ttc']['label'], $_SERVER['PHP_SELF'], 'c.multicurrency_total_ttc', '', $param, 'class="right"', $sortfield, $sortorder);
1320  }
1321  if (!empty($arrayfields['u.login']['checked'])) {
1322  print_liste_field_titre($arrayfields['u.login']['label'], $_SERVER["PHP_SELF"], 'u.login', '', $param, 'align="center"', $sortfield, $sortorder);
1323  }
1324  if (!empty($arrayfields['sale_representative']['checked'])) {
1325  print_liste_field_titre($arrayfields['sale_representative']['label'], $_SERVER["PHP_SELF"], "", "", "$param", '', $sortfield, $sortorder);
1326  }
1327  if (!empty($arrayfields['total_pa']['checked'])) {
1328  print_liste_field_titre($arrayfields['total_pa']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder);
1329  }
1330  if (!empty($arrayfields['total_margin']['checked'])) {
1331  print_liste_field_titre($arrayfields['total_margin']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder);
1332  }
1333  if (!empty($arrayfields['total_margin_rate']['checked'])) {
1334  print_liste_field_titre($arrayfields['total_margin_rate']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder);
1335  }
1336  if (!empty($arrayfields['total_mark_rate']['checked'])) {
1337  print_liste_field_titre($arrayfields['total_mark_rate']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder);
1338  }
1339 
1340  $totalarray = array(
1341  'nbfield' => 0,
1342  'val' => array(
1343  'cdet.total_ht' => 0,
1344  'cdet.total_tva' => 0,
1345  'cdet.total_ttc' => 0,
1346  ),
1347  'pos' => array(),
1348  );
1349  // Extra fields
1350  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
1351  // Hook fields
1352  $parameters = array(
1353  'arrayfields' => $arrayfields,
1354  'param' => $param,
1355  'sortfield' => $sortfield,
1356  'sortorder' => $sortorder,
1357  'totalarray' => &$totalarray,
1358  );
1359  $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
1360  print $hookmanager->resPrint;
1361  if (!empty($arrayfields['c.datec']['checked'])) {
1362  print_liste_field_titre($arrayfields['c.datec']['label'], $_SERVER["PHP_SELF"], "c.date_creation", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
1363  }
1364  if (!empty($arrayfields['c.tms']['checked'])) {
1365  print_liste_field_titre($arrayfields['c.tms']['label'], $_SERVER["PHP_SELF"], "c.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
1366  }
1367  if (!empty($arrayfields['c.date_cloture']['checked'])) {
1368  print_liste_field_titre($arrayfields['c.date_cloture']['label'], $_SERVER["PHP_SELF"], "c.date_cloture", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
1369  }
1370  if (!empty($arrayfields['c.note_public']['checked'])) {
1371  print_liste_field_titre($arrayfields['c.note_public']['label'], $_SERVER["PHP_SELF"], "c.note_public", "", $param, '', $sortfield, $sortorder, 'right ');
1372  }
1373  if (!empty($arrayfields['c.note_private']['checked'])) {
1374  print_liste_field_titre($arrayfields['c.note_private']['label'], $_SERVER["PHP_SELF"], "c.note_private", "", $param, '', $sortfield, $sortorder, 'right ');
1375  }
1376  if (!empty($arrayfields['shippable']['checked'])) {
1377  print_liste_field_titre($arrayfields['shippable']['label'], $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'center ');
1378  }
1379  if (!empty($arrayfields['c.facture']['checked'])) {
1380  print_liste_field_titre($arrayfields['c.facture']['label'], $_SERVER["PHP_SELF"], 'c.facture', '', $param, '', $sortfield, $sortorder, 'center ');
1381  }
1382  if (!empty($arrayfields['c.import_key']['checked'])) {
1383  print_liste_field_titre($arrayfields['c.import_key']['label'], $_SERVER["PHP_SELF"], "c.import_key", "", $param, '', $sortfield, $sortorder, 'center ');
1384  }
1385  if (!empty($arrayfields['c.fk_statut']['checked'])) {
1386  print_liste_field_titre($arrayfields['c.fk_statut']['label'], $_SERVER["PHP_SELF"], "c.fk_statut", "", $param, '', $sortfield, $sortorder, 'center ');
1387  }
1388  if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
1389  print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'maxwidthsearch center ');
1390  }
1391  print '</tr>'."\n";
1392 
1393  $total = 0;
1394  $subtotal = 0;
1395  $productstat_cache = array();
1396  $productstat_cachevirtual = array();
1397  $getNomUrl_cache = array();
1398 
1399  $generic_commande = new Commande($db);
1400  $generic_product = new Product($db);
1401  $userstatic = new User($db);
1402  $i = 0;
1403 
1404  $with_margin_info = false;
1405  if (isModEnabled('margin') && (
1406  !empty($arrayfields['total_pa']['checked'])
1407  || !empty($arrayfields['total_margin']['checked'])
1408  || !empty($arrayfields['total_margin_rate']['checked'])
1409  || !empty($arrayfields['total_mark_rate']['checked'])
1410  )
1411  ) {
1412  $with_margin_info = true;
1413  }
1414  $total_ht = 0;
1415  $total_margin = 0;
1416 
1417 
1418  // Détail commande
1419  $totalqty = 0;
1420 
1421  $totalarray = array();
1422  $totalarray['nbfield'] = 0;
1423  $totalarray['val']['cdet.total_tva'] = 0;
1424  $totalarray['val']['cdet.total_ttc'] = 0;
1425  $imaxinloop = ($limit ? min($num, $limit) : $num);
1426  while ($i < $imaxinloop) {
1427  $obj = $db->fetch_object($resql);
1428 
1429  $notshippable = 0;
1430  $warning = 0;
1431  $text_info = '';
1432  $text_warning = '';
1433  $nbprod = 0;
1434 
1435  // Print SubTotal
1436  if (empty($i)) {
1437  $oldref = $obj->product_ref;
1438  }
1439  if ($oldref != $obj->product_ref && $sortfield == 'pr.ref') {
1440  // TODO make new /core/tpl/list_print_sub_total.php
1441  include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
1442  $oldref = $obj->product_ref;
1443  }
1444 
1445  $companystatic->id = $obj->socid;
1446  $companystatic->name = $obj->name;
1447  $companystatic->name_alias = $obj->alias;
1448  $companystatic->client = $obj->client;
1449  $companystatic->code_client = $obj->code_client;
1450  $companystatic->email = $obj->email;
1451  $companystatic->phone = $obj->phone;
1452  $companystatic->address = $obj->address;
1453  $companystatic->zip = $obj->zip;
1454  $companystatic->town = $obj->town;
1455  $companystatic->country_code = $obj->country_code;
1456  if (!isset($getNomUrl_cache[$obj->socid])) {
1457  $getNomUrl_cache[$obj->socid] = $companystatic->getNomUrl(1, 'customer');
1458  }
1459 
1460  $generic_commande->id = $obj->c_rowid;
1461  $generic_commande->ref = $obj->ref;
1462  $generic_commande->statut = $obj->fk_statut;
1463  $generic_commande->billed = $obj->billed;
1464  $generic_commande->date = $db->jdate($obj->date_commande);
1465  $generic_commande->date_livraison = $db->jdate($obj->date_delivery); // deprecated
1466  $generic_commande->delivery_date = $db->jdate($obj->date_delivery);
1467  $generic_commande->ref_client = $obj->ref_client;
1468  $generic_commande->total_ht = $obj->c_total_ht;
1469  $generic_commande->total_tva = $obj->c_total_tva;
1470  $generic_commande->total_ttc = $obj->c_total_ttc;
1471  $generic_commande->note_public = $obj->note_public;
1472  $generic_commande->note_private = $obj->note_private;
1473 
1474  $projectstatic->id = $obj->project_id;
1475  $projectstatic->ref = $obj->project_ref;
1476  $projectstatic->title = $obj->project_label;
1477 
1478  $marginInfo = array();
1479  if ($with_margin_info === true) {
1480  $generic_commande->fetch_lines();
1481  $marginInfo = $formmargin->getMarginInfosArray($generic_commande);
1482  $total_ht += $obj->total_ht;
1483  $total_margin += $marginInfo['total_margin'];
1484  }
1485 
1486  print '<tr class="oddeven">';
1487 
1488  // Action column
1489  if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
1490  print '<td class="nowrap center">';
1491  if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
1492  $selected = 0;
1493  if (in_array($obj->rowid, $arrayofselected)) {
1494  $selected = 1;
1495  }
1496  print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
1497  }
1498  print '</td>';
1499  if (!$i) {
1500  $totalarray['nbfield']++;
1501  }
1502  }
1503 
1504  // Détail commande
1505  // Product Ref
1506  if (!empty($arrayfields['pr.ref']['checked'])) {
1507  if (!empty($obj->product_rowid)) {
1508  $generic_product->id = $obj->product_rowid;
1509  $generic_product->ref = $obj->product_ref;
1510  $generic_product->label = $obj->product_label;
1511  $generic_product->status = $obj->product_status;
1512  $generic_product->status_buy = $obj->product_status_buy;
1513  $generic_product->status_batch = $obj->product_batch;
1514  $generic_product->barcode = $obj->product_barcode;
1515  print '<td class="nowrap tdoverflowmax200">'.$generic_product->getNomUrl(1).'</td>';
1516  } else {
1517  print '<td class="nowrap tdoverflowmax200">Ligne libre</td>';
1518  }
1519  if (!$i) {
1520  $totalarray['nbfield']++;
1521  }
1522  }
1523  // Product Description
1524  if (!empty($arrayfields['pr.desc']['checked'])) {
1525  // print '<td class="nowrap tdoverflowmax200">'.$obj->description.'</td>';
1526  !empty($obj->product_label) ? $labelproduct = $obj->product_label : $labelproduct = $obj->description;
1527  print '<td class="nowrap tdoverflowmax200">'.dol_escape_htmltag($labelproduct).'</td>';
1528 
1529  if (!$i) {
1530  $totalarray['nbfield']++;
1531  }
1532  }
1533  // Product QtyOrdered
1534  if (!empty($arrayfields['cdet.qty']['checked'])) {
1535  print '<td class="nowrap right">'.$obj->qty.'</td>';
1536  if (isset($totalarray['val']['cdet.qty'])) {
1537  $totalarray['val']['cdet.qty'] += $obj->qty;
1538  } else {
1539  $totalarray['val']['cdet.qty'] = $obj->qty;
1540  }
1541  if (!$i) {
1542  $totalarray['nbfield']++;
1543  }
1544  if (!$i) {
1545  $totalarray['pos'][$totalarray['nbfield']] = 'cdet.qty';
1546  }
1547  }
1548 
1549  // Ref
1550  if (!empty($arrayfields['c.ref']['checked'])) {
1551  print '<td class="nowraponall">';
1552  print $generic_commande->getNomUrl(1, ($search_status != 2 ? 0 : $obj->fk_statut), 0, 0, 0, 1, 1);
1553 
1554  $filename = dol_sanitizeFileName($obj->ref);
1555  $filedir = $conf->commande->multidir_output[$conf->entity].'/'.dol_sanitizeFileName($obj->ref);
1556  $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->rowid;
1557  print $formfile->getDocumentsLink($generic_commande->element, $filename, $filedir);
1558 
1559  print '</td>';
1560  if (!$i) {
1561  $totalarray['nbfield']++;
1562  }
1563  }
1564 
1565  // Ref customer
1566  if (!empty($arrayfields['c.ref_client']['checked'])) {
1567  print '<td class="nowrap tdoverflowmax200">'.$obj->ref_client.'</td>';
1568  if (!$i) {
1569  $totalarray['nbfield']++;
1570  }
1571  }
1572 
1573  // Project ref
1574  if (!empty($arrayfields['p.ref']['checked'])) {
1575  print '<td class="nowrap">';
1576  if ($obj->project_id > 0) {
1577  print $projectstatic->getNomUrl(1);
1578  }
1579  print '</td>';
1580  if (!$i) {
1581  $totalarray['nbfield']++;
1582  }
1583  }
1584 
1585  // Project label
1586  if (!empty($arrayfields['p.title']['checked'])) {
1587  print '<td class="nowrap">';
1588  if ($obj->project_id > 0) {
1589  print $projectstatic->title;
1590  }
1591  print '</td>';
1592  if (!$i) {
1593  $totalarray['nbfield']++;
1594  }
1595  }
1596 
1597  // Third party
1598  if (!empty($arrayfields['s.nom']['checked'])) {
1599  print '<td class="tdoverflowmax200">';
1600  print $getNomUrl_cache[$obj->socid];
1601 
1602  // If module invoices enabled and user with invoice creation permissions
1603  if (isModEnabled('facture') && !empty($conf->global->ORDER_BILLING_ALL_CUSTOMER)) {
1604  if ($user->hasRight('facture', 'creer')) {
1605  if (($obj->fk_statut > 0 && $obj->fk_statut < 3) || ($obj->fk_statut == 3 && $obj->billed == 0)) {
1606  print '&nbsp;<a href="'.DOL_URL_ROOT.'/commande/list.php?socid='.$companystatic->id.'&search_billed=0&autoselectall=1">';
1607  print img_picto($langs->trans("CreateInvoiceForThisCustomer").' : '.$companystatic->name, 'object_bill', 'hideonsmartphone').'</a>';
1608  }
1609  }
1610  }
1611  print '</td>';
1612  if (!$i) {
1613  $totalarray['nbfield']++;
1614  }
1615  }
1616  // Alias name
1617  if (!empty($arrayfields['s.name_alias']['checked'])) {
1618  print '<td class="nocellnopadd">';
1619  print $obj->alias;
1620  print '</td>';
1621  if (!$i) {
1622  $totalarray['nbfield']++;
1623  }
1624  }
1625  // Town
1626  if (!empty($arrayfields['s.town']['checked'])) {
1627  print '<td class="nocellnopadd">';
1628  print $obj->town;
1629  print '</td>';
1630  if (!$i) {
1631  $totalarray['nbfield']++;
1632  }
1633  }
1634  // Zip
1635  if (!empty($arrayfields['s.zip']['checked'])) {
1636  print '<td class="nocellnopadd">';
1637  print $obj->zip;
1638  print '</td>';
1639  if (!$i) {
1640  $totalarray['nbfield']++;
1641  }
1642  }
1643  // State
1644  if (!empty($arrayfields['state.nom']['checked'])) {
1645  print "<td>".$obj->state_name."</td>\n";
1646  if (!$i) {
1647  $totalarray['nbfield']++;
1648  }
1649  }
1650  // Country
1651  if (!empty($arrayfields['country.code_iso']['checked'])) {
1652  print '<td class="center">';
1653  $tmparray = getCountry($obj->fk_pays, 'all');
1654  print $tmparray['label'];
1655  print '</td>';
1656  if (!$i) {
1657  $totalarray['nbfield']++;
1658  }
1659  }
1660  // Type ent
1661  if (!empty($arrayfields['typent.code']['checked'])) {
1662  print '<td class="center">';
1663  if (empty($typenArray)) {
1664  $typenArray = $formcompany->typent_array(1);
1665  }
1666  print $typenArray[$obj->typent_code];
1667  print '</td>';
1668  if (!$i) {
1669  $totalarray['nbfield']++;
1670  }
1671  }
1672 
1673  // Order date
1674  if (!empty($arrayfields['c.date_commande']['checked'])) {
1675  print '<td class="center">';
1676  print dol_print_date($db->jdate($obj->date_commande), 'day');
1677  // Warning late icon and note
1678  if ($generic_commande->hasDelay()) {
1679  print img_picto($langs->trans("Late").' : '.$generic_commande->showDelay(), "warning");
1680  }
1681  print '</td>';
1682  if (!$i) {
1683  $totalarray['nbfield']++;
1684  }
1685  }
1686  // Plannned date of delivery
1687  if (!empty($arrayfields['c.date_delivery']['checked'])) {
1688  print '<td class="center">';
1689  print dol_print_date($db->jdate($obj->date_delivery), 'dayhour');
1690  print '</td>';
1691  if (!$i) {
1692  $totalarray['nbfield']++;
1693  }
1694  }
1695  // Shipping Method
1696  if (!empty($arrayfields['c.fk_shipping_method']['checked'])) {
1697  print '<td>';
1698  $form->formSelectShippingMethod('', $obj->fk_shipping_method, 'none', 1);
1699  print '</td>';
1700  if (!$i) {
1701  $totalarray['nbfield']++;
1702  }
1703  }
1704  // Payment terms
1705  if (!empty($arrayfields['c.fk_cond_reglement']['checked'])) {
1706  print '<td>';
1707  $form->form_conditions_reglement($_SERVER['PHP_SELF'], $obj->fk_cond_reglement, 'none', 0, '', 1, $obj->deposit_percent);
1708  print '</td>';
1709  if (!$i) {
1710  $totalarray['nbfield']++;
1711  }
1712  }
1713  // Payment mode
1714  if (!empty($arrayfields['c.fk_mode_reglement']['checked'])) {
1715  print '<td>';
1716  $form->form_modes_reglement($_SERVER['PHP_SELF'], $obj->fk_mode_reglement, 'none', '', -1);
1717  print '</td>';
1718  if (!$i) {
1719  $totalarray['nbfield']++;
1720  }
1721  }
1722  // Channel
1723  if (!empty($arrayfields['c.fk_input_reason']['checked'])) {
1724  print '<td>';
1725  $form->formInputReason($_SERVER['PHP_SELF'], $obj->fk_input_reason, 'none', '');
1726  print '</td>';
1727  if (!$i) {
1728  $totalarray['nbfield']++;
1729  }
1730  }
1731  // Amount HT
1732  if (!empty($arrayfields['cdet.total_ht']['checked'])) {
1733  print '<td class="nowrap right"><span class="amount">'.price($obj->total_ht)."</span></td>\n";
1734  if (!$i) {
1735  $totalarray['nbfield']++;
1736  }
1737  if (!$i) {
1738  $totalarray['pos'][$totalarray['nbfield']] = 'cdet.total_ht';
1739  }
1740  if (isset($totalarray['val']['cdet.total_ht'])) {
1741  $totalarray['val']['cdet.total_ht'] += $obj->total_ht;
1742  } else {
1743  $totalarray['val']['cdet.total_ht'] = $obj->total_ht;
1744  }
1745  }
1746  // Amount VAT
1747  if (!empty($arrayfields['c.total_vat']['checked'])) {
1748  print '<td class="nowrap right"><span class="amount">'.price($obj->total_tva)."</span></td>\n";
1749  if (!$i) {
1750  $totalarray['nbfield']++;
1751  }
1752  if (!$i) {
1753  $totalarray['pos'][$totalarray['nbfield']] = 'cdet.total_tva';
1754  }
1755  $totalarray['val']['cdet.total_tva'] += $obj->total_tva;
1756  }
1757  // Amount TTC
1758  if (!empty($arrayfields['cdet.total_ttc']['checked'])) {
1759  print '<td class="nowrap right"><span class="amount">'.price($obj->total_ttc)."</span></td>\n";
1760  if (!$i) {
1761  $totalarray['nbfield']++;
1762  }
1763  if (!$i) {
1764  $totalarray['pos'][$totalarray['nbfield']] = 'cdet.total_ttc';
1765  }
1766  $totalarray['val']['cdet.total_ttc'] += $obj->total_ttc;
1767  }
1768  // Warehouse
1769  if (!empty($arrayfields['c.fk_warehouse']['checked'])) {
1770  print '<td class="nowrap">';
1771  if ($obj->warehouse > 0) {
1772  print img_picto('', 'stock', 'class="paddingrightonly"');
1773  }
1774  $formproduct->formSelectWarehouses($_SERVER['PHP_SELF'], $obj->warehouse, 'none');
1775  print "</td>\n";
1776  if (!$i) {
1777  $totalarray['nbfield']++;
1778  }
1779  }
1780  // Currency
1781  if (!empty($arrayfields['c.multicurrency_code']['checked'])) {
1782  print '<td class="nowrap">'.$obj->multicurrency_code.' - '.$langs->trans('Currency'.$obj->multicurrency_code)."</td>\n";
1783  if (!$i) {
1784  $totalarray['nbfield']++;
1785  }
1786  }
1787 
1788  // Currency rate
1789  if (!empty($arrayfields['c.multicurrency_tx']['checked'])) {
1790  print '<td class="nowrap">';
1791  $form->form_multicurrency_rate($_SERVER['PHP_SELF'].'?id='.$obj->rowid, $obj->multicurrency_tx, 'none', $obj->multicurrency_code);
1792  print "</td>\n";
1793  if (!$i) {
1794  $totalarray['nbfield']++;
1795  }
1796  }
1797  // Amount HT
1798  if (!empty($arrayfields['c.multicurrency_total_ht']['checked'])) {
1799  print '<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_ht)."</span></td>\n";
1800  if (!$i) {
1801  $totalarray['nbfield']++;
1802  }
1803  }
1804  // Amount VAT
1805  if (!empty($arrayfields['c.multicurrency_total_vat']['checked'])) {
1806  print '<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_vat)."</span></td>\n";
1807  if (!$i) {
1808  $totalarray['nbfield']++;
1809  }
1810  }
1811  // Amount TTC
1812  if (!empty($arrayfields['c.multicurrency_total_ttc']['checked'])) {
1813  print '<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_ttc)."</span></td>\n";
1814  if (!$i) {
1815  $totalarray['nbfield']++;
1816  }
1817  }
1818 
1819  $userstatic->id = $obj->fk_user_author;
1820  $userstatic->login = $obj->login;
1821  $userstatic->lastname = $obj->lastname;
1822  $userstatic->firstname = $obj->firstname;
1823  $userstatic->email = $obj->user_email;
1824  $userstatic->statut = $obj->user_statut;
1825  $userstatic->entity = $obj->entity;
1826  $userstatic->photo = $obj->photo;
1827  $userstatic->office_phone = $obj->office_phone;
1828  $userstatic->office_fax = $obj->office_fax;
1829  $userstatic->user_mobile = $obj->user_mobile;
1830  $userstatic->job = $obj->job;
1831  $userstatic->gender = $obj->gender;
1832 
1833  // Author
1834  if (!empty($arrayfields['u.login']['checked'])) {
1835  print '<td class="tdoverflowmax200">';
1836  if ($userstatic->id) {
1837  print $userstatic->getNomUrl(-1);
1838  } else {
1839  print '&nbsp;';
1840  }
1841  print "</td>\n";
1842  if (!$i) {
1843  $totalarray['nbfield']++;
1844  }
1845  }
1846 
1847  if (!empty($arrayfields['sale_representative']['checked'])) {
1848  // Sales representatives
1849  print '<td>';
1850  if ($obj->socid > 0) {
1851  $listsalesrepresentatives = $companystatic->getSalesRepresentatives($user);
1852  if ($listsalesrepresentatives < 0) {
1853  dol_print_error($db);
1854  }
1855  $nbofsalesrepresentative = count($listsalesrepresentatives);
1856  if ($nbofsalesrepresentative > 6) {
1857  // We print only number
1858  print $nbofsalesrepresentative;
1859  } elseif ($nbofsalesrepresentative > 0) {
1860  $j = 0;
1861  foreach ($listsalesrepresentatives as $val) {
1862  $userstatic->id = $val['id'];
1863  $userstatic->lastname = $val['lastname'];
1864  $userstatic->firstname = $val['firstname'];
1865  $userstatic->email = $val['email'];
1866  $userstatic->statut = $val['statut'];
1867  $userstatic->entity = $val['entity'];
1868  $userstatic->photo = $val['photo'];
1869  $userstatic->login = $val['login'];
1870  $userstatic->office_phone = $val['office_phone'];
1871  $userstatic->office_fax = $val['office_fax'];
1872  $userstatic->user_mobile = $val['user_mobile'];
1873  $userstatic->job = $val['job'];
1874  $userstatic->gender = $val['gender'];
1875  //print '<div class="float">':
1876  print ($nbofsalesrepresentative < 2) ? $userstatic->getNomUrl(-1, '', 0, 0, 12) : $userstatic->getNomUrl(-2);
1877  $j++;
1878  if ($j < $nbofsalesrepresentative) {
1879  print ' ';
1880  }
1881  //print '</div>';
1882  }
1883  }
1884  //else print $langs->trans("NoSalesRepresentativeAffected");
1885  } else {
1886  print '&nbsp;';
1887  }
1888  print '</td>';
1889  if (!$i) {
1890  $totalarray['nbfield']++;
1891  }
1892  }
1893 
1894  // Total buying or cost price
1895  if (!empty($arrayfields['total_pa']['checked'])) {
1896  print '<td class="right nowrap">'.price($marginInfo['pa_total']).'</td>';
1897  if (!$i) {
1898  $totalarray['nbfield']++;
1899  }
1900  }
1901  // Total margin
1902  if (!empty($arrayfields['total_margin']['checked'])) {
1903  print '<td class="right nowrap">'.price($marginInfo['total_margin']).'</td>';
1904  if (!$i) {
1905  $totalarray['nbfield']++;
1906  }
1907  if (!$i) {
1908  $totalarray['pos'][$totalarray['nbfield']] = 'total_margin';
1909  }
1910  $totalarray['val']['total_margin'] += $marginInfo['total_margin'];
1911  }
1912  // Total margin rate
1913  if (!empty($arrayfields['total_margin_rate']['checked'])) {
1914  print '<td class="right nowrap">'.(($marginInfo['total_margin_rate'] == '') ? '' : price($marginInfo['total_margin_rate'], null, null, null, null, 2).'%').'</td>';
1915  if (!$i) {
1916  $totalarray['nbfield']++;
1917  }
1918  }
1919  // Total mark rate
1920  if (!empty($arrayfields['total_mark_rate']['checked'])) {
1921  print '<td class="right nowrap">'.(($marginInfo['total_mark_rate'] == '') ? '' : price($marginInfo['total_mark_rate'], null, null, null, null, 2).'%').'</td>';
1922  if (!$i) {
1923  $totalarray['nbfield']++;
1924  }
1925  if (!$i) {
1926  $totalarray['pos'][$totalarray['nbfield']] = 'total_mark_rate';
1927  }
1928  if ($i >= $imaxinloop - 1) {
1929  if (!empty($total_ht)) {
1930  $totalarray['val']['total_mark_rate'] = price2num($total_margin * 100 / $total_ht, 'MT');
1931  } else {
1932  $totalarray['val']['total_mark_rate'] = '';
1933  }
1934  }
1935  }
1936 
1937  // Extra fields
1938  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
1939  // Fields from hook
1940  $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
1941  $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1942  print $hookmanager->resPrint;
1943 
1944  // Date creation
1945  if (!empty($arrayfields['c.datec']['checked'])) {
1946  print '<td align="center" class="nowrap">';
1947  print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser');
1948  print '</td>';
1949  if (!$i) {
1950  $totalarray['nbfield']++;
1951  }
1952  }
1953 
1954  // Date modification
1955  if (!empty($arrayfields['c.tms']['checked'])) {
1956  print '<td align="center" class="nowrap">';
1957  print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser');
1958  print '</td>';
1959  if (!$i) {
1960  $totalarray['nbfield']++;
1961  }
1962  }
1963 
1964  // Date cloture
1965  if (!empty($arrayfields['c.date_cloture']['checked'])) {
1966  print '<td align="center" class="nowrap">';
1967  print dol_print_date($db->jdate($obj->date_cloture), 'dayhour', 'tzuser');
1968  print '</td>';
1969  if (!$i) {
1970  $totalarray['nbfield']++;
1971  }
1972  }
1973 
1974  // Note public
1975  if (!empty($arrayfields['c.note_public']['checked'])) {
1976  print '<td class="center">';
1977  print dol_string_nohtmltag($obj->note_public);
1978  print '</td>';
1979  if (!$i) {
1980  $totalarray['nbfield']++;
1981  }
1982  }
1983 
1984  // Note private
1985  if (!empty($arrayfields['c.note_private']['checked'])) {
1986  print '<td class="center">';
1987  print dol_string_nohtmltag($obj->note_private);
1988  print '</td>';
1989  if (!$i) {
1990  $totalarray['nbfield']++;
1991  }
1992  }
1993 
1994  // Show shippable Icon (this creates subloops, so may be slow)
1995  if (!empty($arrayfields['shippable']['checked'])) {
1996  print '<td class="center">';
1997  if (!empty($show_shippable_command) && isModEnabled('stock')) {
1998  if (($obj->fk_statut > $generic_commande::STATUS_DRAFT) && ($obj->fk_statut < $generic_commande::STATUS_CLOSED)) {
1999  $generic_commande->loadExpeditions(); // Load array ->expeditions
2000 
2001  if (isset($generic_commande->expeditions[$obj->rowid])) {
2002  $reliquat = $obj->qty - $generic_commande->expeditions[$obj->rowid];
2003  } else {
2004  $reliquat = $obj->qty;
2005  }
2006  if ($obj->product_type == 0 && $obj->fk_product > 0) { // If line is a product and not a service
2007  $nbprod++; // order contains real products
2008  $generic_product->id = $obj->fk_product;
2009 
2010  // Get local and virtual stock and store it into cache
2011  if (empty($productstat_cache[$obj->fk_product])) {
2012  $generic_product->load_stock('nobatch'); // ->load_virtual_stock() is already included into load_stock()
2013  $productstat_cache[$obj->fk_product]['stock_reel'] = $generic_product->stock_reel;
2014  $productstat_cachevirtual[$obj->fk_product]['stock_reel'] = $generic_product->stock_theorique;
2015  } else {
2016  $generic_product->stock_reel = $productstat_cache[$obj->fk_product]['stock_reel'];
2017  $generic_product->stock_theorique = $productstat_cachevirtual[$obj->fk_product]['stock_reel'] = $generic_product->stock_theorique;
2018  }
2019 
2020  if ($reliquat > $generic_product->stock_reel) {
2021  $notshippable++;
2022  }
2023  if (empty($conf->global->SHIPPABLE_ORDER_ICON_IN_LIST)) { // Default code. Default should be this case.
2024  $text_info .= $reliquat.' x '.$obj->product_ref.'&nbsp;'.dol_trunc($obj->product_label, 20);
2025  $text_info .= ' - '.$langs->trans("Stock").': <span class="'.($generic_product->stock_reel > 0 ? 'ok' : 'error').'">'.$generic_product->stock_reel.'</span>';
2026  $text_info .= ' - '.$langs->trans("VirtualStock").': <span class="'.($generic_product->stock_theorique > 0 ? 'ok' : 'error').'">'.$generic_product->stock_theorique.'</span>';
2027  $text_info .= ($reliquat != $obj->qty ? ' <span class="opacitymedium">('.$langs->trans("QtyInOtherShipments").' '.($obj->qty - $reliquat).')</span>' : '');
2028  $text_info .= '<br>';
2029  } else { // BUGGED CODE.
2030  // DOES NOT TAKE INTO ACCOUNT MANUFACTURING. THIS CODE SHOULD BE USELESS. PREVIOUS CODE SEEMS COMPLETE.
2031  // COUNT STOCK WHEN WE SHOULD ALREADY HAVE VALUE
2032  // Detailed virtual stock, looks bugged, uncomplete and need heavy load.
2033  // stock order and stock order_supplier
2034  $stock_order = 0;
2035  $stock_order_supplier = 0;
2036  if (!empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) || !empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE)) { // What about other options ?
2037  if (isModEnabled('commande')) {
2038  if (empty($productstat_cache[$obj->fk_product]['stats_order_customer'])) {
2039  $generic_product->load_stats_commande(0, '1,2');
2040  $productstat_cache[$obj->fk_product]['stats_order_customer'] = $generic_product->stats_commande['qty'];
2041  } else {
2042  $generic_product->stats_commande['qty'] = $productstat_cache[$obj->fk_product]['stats_order_customer'];
2043  }
2044  $stock_order = $generic_product->stats_commande['qty'];
2045  }
2046  if (isModEnabled('supplier_order')) {
2047  if (empty($productstat_cache[$obj->fk_product]['stats_order_supplier'])) {
2048  $generic_product->load_stats_commande_fournisseur(0, '3');
2049  $productstat_cache[$obj->fk_product]['stats_order_supplier'] = $generic_product->stats_commande_fournisseur['qty'];
2050  } else {
2051  $generic_product->stats_commande_fournisseur['qty'] = $productstat_cache[$obj->fk_product]['stats_order_supplier'];
2052  }
2053  $stock_order_supplier = $generic_product->stats_commande_fournisseur['qty'];
2054  }
2055  }
2056  $text_info .= $reliquat.' x '.$obj->product_ref.'&nbsp;'.dol_trunc($obj->product_label, 20);
2057  $text_stock_reel = $generic_product->stock_reel.'/'.$stock_order;
2058  if ($stock_order > $generic_product->stock_reel && !($generic_product->stock_reel < $obj->qty)) {
2059  $warning++;
2060  $text_warning .= '<span class="warning">'.$langs->trans('Available').'&nbsp;:&nbsp;'.$text_stock_reel.'</span>';
2061  }
2062  if ($reliquat > $generic_product->stock_reel) {
2063  $text_info .= '<span class="warning">'.$langs->trans('Available').'&nbsp;:&nbsp;'.$text_stock_reel.'</span>';
2064  } else {
2065  $text_info .= '<span class="ok">'.$langs->trans('Available').'&nbsp;:&nbsp;'.$text_stock_reel.'</span>';
2066  }
2067  if (isModEnabled('supplier_order')) {
2068  $text_info .= '&nbsp;'.$langs->trans('SupplierOrder').'&nbsp;:&nbsp;'.$stock_order_supplier;
2069  }
2070  $text_info .= ($reliquat != $obj->qty ? ' <span class="opacitymedium">('.$langs->trans("QtyInOtherShipments").' '.($obj->qty - $reliquat).')</span>' : '');
2071  $text_info .= '<br>';
2072  }
2073  }
2074  if ($notshippable == 0) {
2075  $text_icon = img_picto('', 'dolly', '', false, 0, 0, '', 'green paddingleft');
2076  $text_info = $text_icon.' '.$langs->trans('Shippable').'<br>'.$text_info;
2077  } else {
2078  $text_icon = img_picto('', 'dolly', '', false, 0, 0, '', 'error paddingleft');
2079  $text_info = $text_icon.' '.$langs->trans('NonShippable').'<br>'.$text_info;
2080  }
2081  }
2082 
2083  if ($nbprod) {
2084  print $form->textwithtooltip('', $text_info, 2, 1, $text_icon, '', 2);
2085  }
2086  if ($warning) { // Always false in default mode
2087  print $form->textwithtooltip('', $langs->trans('NotEnoughForAllOrders').'<br>'.$text_warning, 2, 1, img_picto('', 'error'), '', 2);
2088  }
2089  }
2090  print '</td>';
2091  if (!$i) {
2092  $totalarray['nbfield']++;
2093  }
2094  }
2095 
2096  // Billed
2097  if (!empty($arrayfields['c.facture']['checked'])) {
2098  print '<td class="center">'.yn($obj->billed).'</td>';
2099  if (!$i) {
2100  $totalarray['nbfield']++;
2101  }
2102  }
2103  // Import key
2104  if (!empty($arrayfields['c.import_key']['checked'])) {
2105  print '<td class="nowrap center">'.$obj->import_key.'</td>';
2106  if (!$i) {
2107  $totalarray['nbfield']++;
2108  }
2109  }
2110  // Status
2111  if (!empty($arrayfields['c.fk_statut']['checked'])) {
2112  print '<td class="nowrap center">'.$generic_commande->LibStatut($obj->fk_statut, $obj->billed, 5, 1).'</td>';
2113  if (!$i) {
2114  $totalarray['nbfield']++;
2115  }
2116  }
2117 
2118  // Action column
2119  if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
2120  print '<td class="nowrap center">';
2121  if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
2122  $selected = 0;
2123  if (in_array($obj->rowid, $arrayofselected)) {
2124  $selected = 1;
2125  }
2126  print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
2127  }
2128  print '</td>';
2129  if (!$i) {
2130  $totalarray['nbfield']++;
2131  }
2132  }
2133  // $totalarray['nbfield']--;
2134  // $totalarray['nbfield']--;
2135  print "</tr>\n";
2136 
2137  $total += $obj->total_ht;
2138  $subtotal += $obj->total_ht;
2139  $i++;
2140  }
2141 
2142  // Show total line
2143  include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
2144 
2145  // If no record found
2146  if ($num == 0) {
2147  $colspan = 1;
2148  foreach ($arrayfields as $key => $val) {
2149  if (!empty($val['checked'])) {
2150  $colspan++;
2151  }
2152  }
2153  print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
2154  }
2155 
2156  $db->free($resql);
2157 
2158  $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql);
2159  $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook
2160  print $hookmanager->resPrint;
2161 
2162  print '</table>'."\n";
2163  print '</div>';
2164 
2165  print '</form>'."\n";
2166 
2167  $hidegeneratedfilelistifempty = 1;
2168  if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) {
2169  $hidegeneratedfilelistifempty = 0;
2170  }
2171 
2172  // Show list of available documents
2173  $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
2174  $urlsource .= str_replace('&amp;', '&', $param);
2175 
2176  $filedir = $diroutputmassaction;
2177  $genallowed = $permissiontoread;
2178  $delallowed = $permissiontoadd;
2179 
2180  print $formfile->showdocuments('massfilesarea_orders', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
2181 } else {
2182  dol_print_error($db);
2183 }
2184 
2185 // End of page
2186 llxFooter();
2187 $db->close();
Societe
Class to manage third parties objects (customers, suppliers, prospects...)
Definition: societe.class.php:51
dol_trunc
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.
Definition: functions.lib.php:4059
dol_sanitizeFileName
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
Definition: functions.lib.php:1323
llxFooter
llxFooter()
Empty footer.
Definition: wrapper.php:70
Project
Class to manage projects.
Definition: project.class.php:36
GETPOST
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Definition: functions.lib.php:609
dol_print_error
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
Definition: functions.lib.php:5107
dol_sort_array
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...
Definition: functions.lib.php:8922
Commande\STATUS_CLOSED
const STATUS_CLOSED
Closed (Sent, billed or not)
Definition: commande.class.php:408
Commande\STATUS_SHIPMENTONPROCESS
const STATUS_SHIPMENTONPROCESS
Shipment on process.
Definition: commande.class.php:402
$form
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:143
FormMargin
Classe permettant la generation de composants html autre Only common components are here.
Definition: html.formmargin.class.php:29
FormOther
Classe permettant la generation de composants html autre Only common components are here.
Definition: html.formother.class.php:39
Commande\STATUS_CANCELED
const STATUS_CANCELED
Canceled status.
Definition: commande.class.php:390
$help_url
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save" &&empty($cancel)) $help_url
View.
Definition: agenda.php:118
price2num
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
Definition: functions.lib.php:5955
dol_print_date
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
Definition: functions.lib.php:2675
FormCompany
Class to build HTML component for third parties management Only common components are here.
Definition: html.formcompany.class.php:40
img_picto
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
Definition: functions.lib.php:4135
Commande\STATUS_VALIDATED
const STATUS_VALIDATED
Validated status.
Definition: commande.class.php:398
llxHeader
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:56
FormFile
Class to offer components to list and upload files.
Definition: html.formfile.class.php:36
Commande
Class to manage customers orders.
Definition: commande.class.php:47
dol_string_nohtmltag
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto='UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
Definition: functions.lib.php:7046
print_barre_liste
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.
Definition: functions.lib.php:5530
setEventMessages
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
Definition: functions.lib.php:8673
$sql
if(isModEnabled('facture') && $user->hasRight('facture', 'lire')) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') && $user->hasRight('don', 'lire')) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $sql
Social contributions to pay.
Definition: index.php:746
restrictedArea
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.
Definition: security.lib.php:353
FormProduct
Class with static methods for building HTML components related to products Only components common to ...
Definition: html.formproduct.class.php:30
Commande\STATUS_DRAFT
const STATUS_DRAFT
Draft status.
Definition: commande.class.php:394
isModEnabled
isModEnabled($module)
Is Dolibarr module enabled.
Definition: functions.lib.php:207
getDolGlobalString
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
Definition: functions.lib.php:142
User
Class to manage Dolibarr users.
Definition: user.class.php:47
GETPOSTISSET
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
Definition: functions.lib.php:509
print_liste_field_titre
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
Definition: functions.lib.php:5295
natural_search
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...
Definition: functions.lib.php:10024
ExtraFields
Class to manage standard extra fields.
Definition: extrafields.class.php:39
Product
Class to manage products or services.
Definition: product.class.php:46
Form
Class to manage generation of HTML components Only common components must be here.
Definition: html.form.class.php:53
dol_now
dol_now($mode='auto')
Return date for now.
Definition: functions.lib.php:3056
price
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.
Definition: functions.lib.php:5829
getCountry
getCountry($searchkey, $withcode='', $dbtouse=0, $outputlangs='', $entconv=1, $searchlabel='')
Return country label, code or id from an id, code or label.
Definition: company.lib.php:515
dol_mktime
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...
Definition: functions.lib.php:2968
getDolGlobalInt
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
Definition: functions.lib.php:156