dolibarr 21.0.0-alpha
list.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2001-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2004-2016 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
5 * Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
6 * Copyright (C) 2005-2013 Regis Houssin <regis.houssin@inodbox.com>
7 * Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
8 * Copyright (C) 2010-2011 Juanjo Menent <jmenent@2byte.es>
9 * Copyright (C) 2010-2022 Philippe Grand <philippe.grand@atoo-net.com>
10 * Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr>
11 * Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr>
12 * Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
13 * Copyright (C) 2016-2021 Ferran Marcet <fmarcet@2byte.es>
14 * Copyright (C) 2017-2023 Charlene Benke <charlene@patas-monkey.com>
15 * Copyright (C) 2018 Nicolas ZABOURI <info@inovea-conseil.com>
16 * Copyright (C) 2019-2024 Alexandre Spangaro <alexandre@inovea-conseil.com>
17 * Copyright (C) 2021 Anthony Berton <anthony.berton@bb2a.fr>
18 * Copyright (C) 2021-2024 Frédéric France <frederic.france@free.fr>
19 * Copyright (C) 2022 Josep Lluís Amador <joseplluis@lliuretic.cat>
20 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
21 * Copyright (C) 2024 William Mead <william.mead@manchenumerique.fr>
22 *
23 * This program is free software; you can redistribute it and/or modify
24 * it under the terms of the GNU General Public License as published by
25 * the Free Software Foundation; either version 3 of the License, or
26 * (at your option) any later version.
27 *
28 * This program is distributed in the hope that it will be useful,
29 * but WITHOUT ANY WARRANTY; without even the implied warranty of
30 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
31 * GNU General Public License for more details.
32 *
33 * You should have received a copy of the GNU General Public License
34 * along with this program. If not, see <https://www.gnu.org/licenses/>.
35 */
36
43// Load Dolibarr environment
44require '../../main.inc.php';
45require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
46require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
47require_once DOL_DOCUMENT_ROOT.'/core/class/html.formpropal.class.php';
48require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
49if (isModEnabled('margin')) {
50 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formmargin.class.php';
51}
52require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
53require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
54require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
55require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
56if (isModEnabled('category')) {
57 require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
58 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcategory.class.php';
59}
60
61// Load translation files required by the page
62$langs->loadLangs(array('companies', 'propal', 'compta', 'bills', 'orders', 'products', 'deliveries', 'categories'));
63if (isModEnabled("shipping")) {
64 $langs->loadLangs(array('sendings'));
65}
66
67// Get Parameters
68$socid = GETPOSTINT('socid');
69
70$action = GETPOST('action', 'aZ09');
71$massaction = GETPOST('massaction', 'alpha');
72$show_files = GETPOSTINT('show_files');
73$confirm = GETPOST('confirm', 'alpha');
74$cancel = GETPOST('cancel', 'alpha');
75$toselect = GETPOST('toselect', 'array');
76$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'proposallist';
77$optioncss = GETPOST('optioncss', 'alpha');
78$mode = GETPOST('mode', 'alpha');
79
80// Search Fields
81$search_all = trim((GETPOST('search_all', 'alphanohtml') != '') ? GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml'));
82$search_user = GETPOSTINT('search_user');
83if ($search_user == -1) {
84 $search_user = 0;
85}
86$search_sale = GETPOSTINT('search_sale');
87$search_ref = GETPOST('sf_ref') ? GETPOST('sf_ref', 'alpha') : GETPOST('search_ref', 'alpha');
88$search_refcustomer = GETPOST('search_refcustomer', 'alpha');
89$search_refproject = GETPOST('search_refproject', 'alpha');
90$search_project = GETPOST('search_project', 'alpha');
91$search_societe = GETPOST('search_societe', 'alpha');
92$search_societe_alias = GETPOST('search_societe_alias', 'alpha');
93$search_montant_ht = GETPOST('search_montant_ht', 'alpha');
94$search_montant_vat = GETPOST('search_montant_vat', 'alpha');
95$search_montant_ttc = GETPOST('search_montant_ttc', 'alpha');
96$search_warehouse = GETPOST('search_warehouse', 'alpha');
97$search_multicurrency_code = GETPOST('search_multicurrency_code', 'alpha');
98$search_multicurrency_tx = GETPOST('search_multicurrency_tx', 'alpha');
99$search_multicurrency_montant_ht = GETPOST('search_multicurrency_montant_ht', 'alpha');
100$search_multicurrency_montant_vat = GETPOST('search_multicurrency_montant_vat', 'alpha');
101$search_multicurrency_montant_ttc = GETPOST('search_multicurrency_montant_ttc', 'alpha');
102$search_login = GETPOST('search_login', 'alpha');
103$search_product_category = GETPOSTINT('search_product_category');
104$search_town = GETPOST('search_town', 'alpha');
105$search_zip = GETPOST('search_zip', 'alpha');
106$search_state = GETPOST("search_state");
107$search_country = GETPOST("search_country", 'aZ09');
108$search_type_thirdparty = GETPOST("search_type_thirdparty", 'intcomma');
109$search_date_startday = GETPOSTINT('search_date_startday');
110$search_date_startmonth = GETPOSTINT('search_date_startmonth');
111$search_date_startyear = GETPOSTINT('search_date_startyear');
112$search_date_endday = GETPOSTINT('search_date_endday');
113$search_date_endmonth = GETPOSTINT('search_date_endmonth');
114$search_date_endyear = GETPOSTINT('search_date_endyear');
115$search_date_start = dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear); // Use tzserver
116$search_date_end = dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear);
117$search_date_end_startday = GETPOSTINT('search_date_end_startday');
118$search_date_end_startmonth = GETPOSTINT('search_date_end_startmonth');
119$search_date_end_startyear = GETPOSTINT('search_date_end_startyear');
120$search_date_end_endday = GETPOSTINT('search_date_end_endday');
121$search_date_end_endmonth = GETPOSTINT('search_date_end_endmonth');
122$search_date_end_endyear = GETPOSTINT('search_date_end_endyear');
123$search_date_end_start = dol_mktime(0, 0, 0, $search_date_end_startmonth, $search_date_end_startday, $search_date_end_startyear); // Use tzserver
124$search_date_end_end = dol_mktime(23, 59, 59, $search_date_end_endmonth, $search_date_end_endday, $search_date_end_endyear);
125$search_date_delivery_startday = GETPOSTINT('search_date_delivery_startday');
126$search_date_delivery_startmonth = GETPOSTINT('search_date_delivery_startmonth');
127$search_date_delivery_startyear = GETPOSTINT('search_date_delivery_startyear');
128$search_date_delivery_endday = GETPOSTINT('search_date_delivery_endday');
129$search_date_delivery_endmonth = GETPOSTINT('search_date_delivery_endmonth');
130$search_date_delivery_endyear = GETPOSTINT('search_date_delivery_endyear');
131$search_date_delivery_start = dol_mktime(0, 0, 0, $search_date_delivery_startmonth, $search_date_delivery_startday, $search_date_delivery_startyear);
132$search_date_delivery_end = dol_mktime(23, 59, 59, $search_date_delivery_endmonth, $search_date_delivery_endday, $search_date_delivery_endyear);
133$search_availability = GETPOST('search_availability', 'intcomma');
134$search_categ_cus = GETPOST("search_categ_cus", 'intcomma');
135$search_fk_cond_reglement = GETPOST("search_fk_cond_reglement", 'intcomma');
136$search_fk_shipping_method = GETPOST("search_fk_shipping_method", 'intcomma');
137$search_fk_input_reason = GETPOST("search_fk_input_reason", 'intcomma');
138$search_fk_mode_reglement = GETPOST("search_fk_mode_reglement", 'intcomma');
139$search_date_signature_startday = GETPOSTINT('search_date_signature_startday');
140$search_date_signature_startmonth = GETPOSTINT('search_date_signature_startmonth');
141$search_date_signature_startyear = GETPOSTINT('search_date_signature_startyear');
142$search_date_signature_endday = GETPOSTINT('search_date_signature_endday');
143$search_date_signature_endmonth = GETPOSTINT('search_date_signature_endmonth');
144$search_date_signature_endyear = GETPOSTINT('search_date_signature_endyear');
145$search_date_signature_start = dol_mktime(0, 0, 0, $search_date_signature_startmonth, $search_date_signature_startday, $search_date_signature_startyear);
146$search_date_signature_end = dol_mktime(23, 59, 59, $search_date_signature_endmonth, $search_date_signature_endday, $search_date_signature_endyear);
147$search_status = GETPOST('search_status', 'alpha');
148$search_note_public = GETPOST('search_note_public', 'alpha');
149
150$search_option = GETPOST('search_option', 'alpha');
151if ($search_option == 'late') {
152 $search_status = '1';
153 $object_statut = '1';
154}
155
156// Pagination
157$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
158$sortfield = GETPOST('sortfield', 'aZ09comma');
159$sortorder = GETPOST('sortorder', 'aZ09comma');
160$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page");
161if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
162 // If $page is not defined, or '' or -1 or if we click on clear filters
163 $page = 0;
164}
165$offset = $limit * $page;
166$pageprev = $page - 1;
167$pagenext = $page + 1;
168if (!$sortfield) {
169 $sortfield = 'p.ref';
170}
171if (!$sortorder) {
172 $sortorder = 'DESC';
173}
174
175// Security check
176$module = 'propal';
177$dbtable = '';
178$objectid = '';
179if (!empty($user->socid)) {
180 $socid = $user->socid;
181}
182if (!empty($socid)) {
183 $objectid = $socid;
184 $module = 'societe';
185 $dbtable = '&societe';
186}
187$hookmanager->initHooks(array('propallist'));
188$result = restrictedArea($user, $module, $objectid, $dbtable);
189
190$diroutputmassaction = $conf->propal->multidir_output[$conf->entity].'/temp/massgeneration/'.$user->id;
191
192// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
193$object = new Propal($db);
194$extrafields = new ExtraFields($db);
195
196// fetch optionals attributes and labels
197$extrafields->fetch_name_optionals_label($object->table_element);
198
199$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
200
201// List of fields to search into when doing a "search in all"
202$fieldstosearchall = array(
203 'p.ref' => 'Ref',
204 'p.ref_client' => 'RefCustomer',
205 'pd.description' => 'Description',
206 's.nom' => "ThirdParty",
207 's.name_alias' => "AliasNameShort",
208 's.zip' => "Zip",
209 's.town' => "Town",
210 'p.note_public' => 'NotePublic',
211);
212if (empty($user->socid)) {
213 $fieldstosearchall["p.note_private"] = "NotePrivate";
214}
215
216
217$checkedtypetiers = 0;
218$arrayfields = array(
219 'p.ref' => array('label' => "Ref", 'checked' => 1),
220 'p.ref_client' => array('label' => "RefCustomer", 'checked' => -1),
221 'pr.ref' => array('label' => "ProjectRef", 'checked' => 1, 'enabled' => (isModEnabled('project') ? 1 : 0)),
222 'pr.title' => array('label' => "ProjectLabel", 'checked' => 0, 'enabled' => (isModEnabled('project') ? 1 : 0)),
223 's.nom' => array('label' => "ThirdParty", 'checked' => 1),
224 's.name_alias' => array('label' => "AliasNameShort", 'checked' => -1),
225 's.town' => array('label' => "Town", 'checked' => -1),
226 's.zip' => array('label' => "Zip", 'checked' => -1),
227 'state.nom' => array('label' => "StateShort", 'checked' => 0),
228 'country.code_iso' => array('label' => "Country", 'checked' => 0),
229 'typent.code' => array('label' => "ThirdPartyType", 'checked' => $checkedtypetiers),
230 'p.date' => array('label' => "DatePropal", 'checked' => 1),
231 'p.fin_validite' => array('label' => "DateEnd", 'checked' => 1),
232 'p.date_livraison' => array('label' => "DeliveryDate", 'checked' => 0),
233 'p.date_signature' => array('label' => "DateSigning", 'checked' => 0),
234 'ava.rowid' => array('label' => "AvailabilityPeriod", 'checked' => 0),
235 'p.fk_shipping_method' => array('label' => "SendingMethod", 'checked' => 0, 'enabled' => isModEnabled("shipping")),
236 'p.fk_input_reason' => array('label' => "Origin", 'checked' => 0, 'enabled' => 1),
237 'p.fk_cond_reglement' => array('label' => "PaymentConditionsShort", 'checked' => 0),
238 'p.fk_mode_reglement' => array('label' => "PaymentMode", 'checked' => 0),
239 'p.total_ht' => array('label' => "AmountHT", 'checked' => 1),
240 'p.total_tva' => array('label' => "AmountVAT", 'checked' => 0),
241 'p.total_ttc' => array('label' => "AmountTTC", 'checked' => 0),
242 'p.total_ht_invoiced' => array('label' => "AmountInvoicedHT", 'checked' => 0, 'enabled' => getDolGlobalString('PROPOSAL_SHOW_INVOICED_AMOUNT')),
243 'p.total_invoiced' => array('label' => "AmountInvoicedTTC", 'checked' => 0, 'enabled' => getDolGlobalString('PROPOSAL_SHOW_INVOICED_AMOUNT')),
244 'p.multicurrency_code' => array('label' => 'Currency', 'checked' => 0, 'enabled' => (!isModEnabled("multicurrency") ? 0 : 1)),
245 'p.multicurrency_tx' => array('label' => 'CurrencyRate', 'checked' => 0, 'enabled' => (!isModEnabled("multicurrency") ? 0 : 1)),
246 'p.multicurrency_total_ht' => array('label' => 'MulticurrencyAmountHT', 'checked' => 0, 'enabled' => (!isModEnabled("multicurrency") ? 0 : 1)),
247 'p.multicurrency_total_tva' => array('label' => 'MulticurrencyAmountVAT', 'checked' => 0, 'enabled' => (!isModEnabled("multicurrency") ? 0 : 1)),
248 'p.multicurrency_total_ttc' => array('label' => 'MulticurrencyAmountTTC', 'checked' => 0, 'enabled' => (!isModEnabled("multicurrency") ? 0 : 1)),
249 'p.multicurrency_total_ht_invoiced' => array('label' => 'MulticurrencyAmountInvoicedHT', 'checked' => 0, 'enabled' => isModEnabled("multicurrency") && getDolGlobalString('PROPOSAL_SHOW_INVOICED_AMOUNT')),
250 'p.multicurrency_total_invoiced' => array('label' => 'MulticurrencyAmountInvoicedTTC', 'checked' => 0, 'enabled' => isModEnabled("multicurrency") && getDolGlobalString('PROPOSAL_SHOW_INVOICED_AMOUNT')),
251 'u.login' => array('label' => "Author", 'checked' => 1, 'position' => 10),
252 'sale_representative' => array('label' => "SaleRepresentativesOfThirdParty", 'checked' => -1),
253 'total_pa' => array('label' => (getDolGlobalString('MARGIN_TYPE') == '1' ? 'BuyingPrice' : 'CostPrice'), 'checked' => 0, 'position' => 300, 'enabled' => (!isModEnabled('margin') || !$user->hasRight('margins', 'liretous') ? 0 : 1)),
254 'total_margin' => array('label' => 'Margin', 'checked' => 0, 'position' => 301, 'enabled' => (!isModEnabled('margin') || !$user->hasRight('margins', 'liretous') ? 0 : 1)),
255 'total_margin_rate' => array('label' => 'MarginRate', 'checked' => 0, 'position' => 302, 'enabled' => (!isModEnabled('margin') || !$user->hasRight('margins', 'liretous') || !getDolGlobalString('DISPLAY_MARGIN_RATES') ? 0 : 1)),
256 'total_mark_rate' => array('label' => 'MarkRate', 'checked' => 0, 'position' => 303, 'enabled' => (!isModEnabled('margin') || !$user->hasRight('margins', 'liretous') || !getDolGlobalString('DISPLAY_MARK_RATES') ? 0 : 1)),
257 'p.datec' => array('label' => "DateCreation", 'checked' => 0, 'position' => 500),
258 'p.tms' => array('label' => "DateModificationShort", 'checked' => 0, 'position' => 500),
259 'p.date_cloture' => array('label' => "DateClosing", 'checked' => 0, 'position' => 500),
260 'p.note_public' => array('label' => 'NotePublic', 'checked' => 0, 'position' => 510, 'enabled' => (!getDolGlobalInt('MAIN_LIST_HIDE_PUBLIC_NOTES'))),
261 'p.note_private' => array('label' => 'NotePrivate', 'checked' => 0, 'position' => 511, 'enabled' => (!getDolGlobalInt('MAIN_LIST_HIDE_PRIVATE_NOTES'))),
262 'p.fk_statut' => array('label' => "Status", 'checked' => 1, 'position' => 1000),
263);
264
265// List of fields to search into when doing a "search in all"
266/*$fieldstosearchall = array();
267 foreach ($object->fields as $key => $val) {
268 if (!empty($val['searchall'])) {
269 $fieldstosearchall['t.'.$key] = $val['label'];
270 }
271 }*/
272
273// Definition of array of fields for columns
274/*$arrayfields = array();
275foreach ($object->fields as $key => $val) {
276 // If $val['visible']==0, then we never show the field
277 if (!empty($val['visible'])) {
278 $visible = (int) dol_eval((string) $val['visible'], 1);
279 $arrayfields['t.'.$key] = array(
280 'label'=>$val['label'],
281 'checked'=>(($visible < 0) ? 0 : 1),
282 'enabled'=>(abs($visible) != 3 && (bool) dol_eval($val['enabled'], 1)),
283 'position'=>$val['position'],
284 'help'=> isset($val['help']) ? $val['help'] : ''
285 );
286 }
287}*/
288
289if (!$user->hasRight('societe', 'client', 'voir')) {
290 $search_sale = $user->id;
291}
292
293// Extra fields
294include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
295
296// Permissions
297$permissiontoread = $user->hasRight('propal', 'lire');
298$permissiontoadd = $user->hasRight('propal', 'creer');
299$permissiontodelete = $user->hasRight('propal', 'supprimer');
300if (getDolGlobalString('MAIN_USE_ADVANCED_PERMS')) {
301 $permissiontovalidate = $user->hasRight('propal', 'propal_advance', 'validate');
302 $permissiontoclose = $user->hasRight('propal', 'propal_advance', 'close');
303 $permissiontosendbymail = $user->hasRight('propal', 'propal_advance', 'send');
304} else {
305 $permissiontovalidate = $user->hasRight('propal', 'creer');
306 $permissiontoclose = $user->hasRight('propal', 'creer');
307 $permissiontosendbymail = $user->hasRight('propal', 'lire');
308}
309
310
311/*
312 * Actions
313 */
314
315if (GETPOST('cancel', 'alpha')) {
316 $action = 'list';
317 $massaction = '';
318}
319if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
320 $massaction = '';
321}
322
323$objectclass = null;
324$search_code_client = '';
325
326$parameters = array('socid' => $socid, 'arrayfields' => &$arrayfields);
327$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
328if ($reshook < 0) {
329 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
330}
331
332if (empty($reshook)) {
333 // Selection of new fields
334 include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
335
336 // Purge search criteria
337 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
338 $search_user = '';
339 $search_sale = '';
340 $search_ref = '';
341 $search_refcustomer = '';
342 $search_refproject = '';
343 $search_project = '';
344 $search_societe = '';
345 $search_societe_alias = '';
346 $search_montant_ht = '';
347 $search_montant_vat = '';
348 $search_montant_ttc = '';
349 $search_warehouse = '';
350 $search_multicurrency_code = '';
351 $search_multicurrency_tx = '';
352 $search_multicurrency_montant_ht = '';
353 $search_multicurrency_montant_vat = '';
354 $search_multicurrency_montant_ttc = '';
355 $search_login = '';
356 $search_product_category = '';
357 $search_town = '';
358 $search_zip = "";
359 $search_state = "";
360 $search_type = '';
361 $search_country = '';
362 $search_type_thirdparty = '';
363 $search_date_startday = '';
364 $search_date_startmonth = '';
365 $search_date_startyear = '';
366 $search_date_endday = '';
367 $search_date_endmonth = '';
368 $search_date_endyear = '';
369 $search_date_start = '';
370 $search_date_end = '';
371 $search_date_end_startday = '';
372 $search_date_end_startmonth = '';
373 $search_date_end_startyear = '';
374 $search_date_end_endday = '';
375 $search_date_end_endmonth = '';
376 $search_date_end_endyear = '';
377 $search_date_end_start = '';
378 $search_date_end_end = '';
379 $search_date_delivery_startday = '';
380 $search_date_delivery_startmonth = '';
381 $search_date_delivery_startyear = '';
382 $search_date_delivery_endday = '';
383 $search_date_delivery_endmonth = '';
384 $search_date_delivery_endyear = '';
385 $search_date_delivery_start = '';
386 $search_date_delivery_end = '';
387 $search_availability = '';
388 $search_option = '';
389 $search_status = '';
390 $search_categ_cus = 0;
391 $search_fk_cond_reglement = '';
392 $search_fk_shipping_method = '';
393 $search_fk_input_reason = '';
394 $search_fk_mode_reglement = '';
395 $search_date_signature_startday = '';
396 $search_date_signature_startmonth = '';
397 $search_date_signature_startyear = '';
398 $search_date_signature_endday = '';
399 $search_date_signature_endmonth = '';
400 $search_date_signature_endyear = '';
401 $search_date_signature_start = '';
402 $search_date_signature_end = '';
403 $toselect = array();
404 $search_array_options = array();
405 $socid = 0;
406 }
407
408 // Mass actions
409 $objectclass = 'Propal';
410 $objectlabel = 'Proposals';
411 $uploaddir = $conf->propal->multidir_output[$conf->entity];
412 include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
413}
414
415if ($action == 'validate' && $permissiontovalidate) {
416 if (GETPOST('confirm') == 'yes') {
417 $tmpproposal = new Propal($db);
418 $db->begin();
419 $error = 0;
420 foreach ($toselect as $checked) {
421 if ($tmpproposal->fetch($checked) > 0) {
422 if ($tmpproposal->statut == $tmpproposal::STATUS_DRAFT) {
423 if ($tmpproposal->valid($user) > 0) {
424 setEventMessages($langs->trans('hasBeenValidated', $tmpproposal->ref), null, 'mesgs');
425 } else {
426 setEventMessages($tmpproposal->error, $tmpproposal->errors, 'errors');
427 $error++;
428 }
429 } else {
430 $langs->load("errors");
431 setEventMessages($langs->trans('ErrorIsNotADraft', $tmpproposal->ref), null, 'errors');
432 $error++;
433 }
434 } else {
435 setEventMessages($tmpproposal->error, $tmpproposal->errors, 'errors');
436 $error++;
437 }
438 }
439 if ($error) {
440 $db->rollback();
441 } else {
442 $db->commit();
443 }
444 }
445}
446
447if ($action == "sign" && $permissiontoclose) {
448 if (GETPOST('confirm') == 'yes') {
449 $tmpproposal = new Propal($db);
450 $db->begin();
451 $error = 0;
452 foreach ($toselect as $checked) {
453 if ($tmpproposal->fetch($checked) > 0) {
454 if ($tmpproposal->statut == $tmpproposal::STATUS_VALIDATED) {
455 $tmpproposal->statut = $tmpproposal::STATUS_SIGNED;
456 if ($tmpproposal->closeProposal($user, $tmpproposal::STATUS_SIGNED) >= 0) {
457 setEventMessages($tmpproposal->ref." ".$langs->trans('Signed'), null, 'mesgs');
458 } else {
459 setEventMessages($tmpproposal->error, $tmpproposal->errors, 'errors');
460 $error++;
461 }
462 } else {
463 setEventMessage($langs->trans('MustBeValidatedToBeSigned', $tmpproposal->ref), 'errors');
464 $error++;
465 }
466 } else {
467 setEventMessages($tmpproposal->error, $tmpproposal->errors, 'errors');
468 $error++;
469 }
470 }
471 if ($error) {
472 $db->rollback();
473 } else {
474 $db->commit();
475 }
476 }
477}
478
479if ($action == "nosign" && $permissiontoclose) {
480 if (GETPOST('confirm') == 'yes') {
481 $tmpproposal = new Propal($db);
482 $db->begin();
483 $error = 0;
484 foreach ($toselect as $checked) {
485 if ($tmpproposal->fetch($checked) > 0) {
486 if ($tmpproposal->statut == $tmpproposal::STATUS_VALIDATED || (getDolGlobalString('PROPAL_SKIP_ACCEPT_REFUSE') && $tmpproposal->statut == $tmpproposal::STATUS_DRAFT)) {
487 $tmpproposal->statut = $tmpproposal::STATUS_NOTSIGNED;
488 if ($tmpproposal->closeProposal($user, $tmpproposal::STATUS_NOTSIGNED) > 0) {
489 setEventMessage($tmpproposal->ref." ".$langs->trans('NoSigned'), 'mesgs');
490 } else {
491 setEventMessages($tmpproposal->error, $tmpproposal->errors, 'errors');
492 $error++;
493 }
494 } else {
495 setEventMessage($tmpproposal->ref." ".$langs->trans('CantBeNoSign'), 'errors');
496 $error++;
497 }
498 } else {
499 setEventMessages($tmpproposal->error, $tmpproposal->errors, 'errors');
500 $error++;
501 }
502 }
503 if ($error) {
504 $db->rollback();
505 } else {
506 $db->commit();
507 }
508 }
509}
510
511// Closed records
512if (!$error && $massaction === 'setbilled' && $permissiontoclose && $objectclass !== null) {
513 $db->begin();
514
515 $objecttmp = new $objectclass($db);
516 $nbok = 0;
517 foreach ($toselect as $toselectid) {
518 $result = $objecttmp->fetch($toselectid);
519 if ($result > 0) {
520 $result = $objecttmp->classifyBilled($user, 0);
521 if ($result <= 0) {
522 setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
523 $error++;
524 break;
525 } else {
526 $nbok++;
527 }
528 } else {
529 setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
530 $error++;
531 break;
532 }
533 }
534
535 if (!$error) {
536 setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs');
537 $db->commit();
538 } else {
539 $db->rollback();
540 }
541}
542
543
544
545/*
546 * View
547 */
548
549$now = dol_now();
550
551$form = new Form($db);
552$formother = new FormOther($db);
553$formfile = new FormFile($db);
554$formpropal = new FormPropal($db);
555$formmargin = null;
556if (isModEnabled('margin')) {
557 $formmargin = new FormMargin($db);
558}
559$companystatic = new Societe($db);
560$projectstatic = new Project($db);
561$formcompany = new FormCompany($db);
562
563$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
564$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
565
566$sql = 'SELECT';
567if ($search_all !== '') {
568 $sql = 'SELECT DISTINCT';
569}
570$sql .= ' s.rowid as socid, s.nom as name, s.name_alias as alias, s.email, s.phone, s.fax , s.address, s.town, s.zip, s.fk_pays, s.client, s.fournisseur, s.code_client,';
571$sql .= " typent.code as typent_code,";
572$sql .= " ava.rowid as availability,";
573$sql .= " country.code as country_code,";
574$sql .= " state.code_departement as state_code, state.nom as state_name,";
575$sql .= ' p.rowid, p.entity as propal_entity, p.note_private, p.total_ht, p.total_tva, p.total_ttc, p.localtax1, p.localtax2, p.ref, p.ref_client, p.fk_statut as status, p.fk_user_author, p.datep as dp, p.fin_validite as dfv, p.date_livraison as ddelivery,';
576$sql .= ' p.fk_multicurrency, p.multicurrency_code, p.multicurrency_tx, p.multicurrency_total_ht, p.multicurrency_total_tva, p.multicurrency_total_ttc,';
577$sql .= ' p.datec as date_creation, p.tms as date_modification, p.date_cloture as date_cloture,';
578$sql .= ' p.date_signature as dsignature,';
579$sql .= ' p.note_public, p.note_private,';
580$sql .= ' p.fk_cond_reglement,p.deposit_percent,p.fk_mode_reglement,p.fk_shipping_method,p.fk_input_reason,';
581$sql .= " pr.rowid as project_id, pr.ref as project_ref, pr.title as project_label,";
582$sql .= ' u.login, u.lastname, u.firstname, u.email as user_email, u.statut as user_statut, u.entity as user_entity, u.photo, u.office_phone, u.office_fax, u.user_mobile, u.job, u.gender';
583// Add fields from extrafields
584if (!empty($extrafields->attributes[$object->table_element]['label'])) {
585 foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
586 $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : '');
587 }
588}
589// Add fields from hooks
590$parameters = array();
591$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
592$sql .= $hookmanager->resPrint;
593$sql = preg_replace('/, $/', '', $sql);
594
595$sqlfields = $sql; // $sql fields to remove for count total
596
597$sql .= ' FROM '.MAIN_DB_PREFIX.'societe as s';
598$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays)";
599$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typent)";
600$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)";
601
602$sql .= ' INNER JOIN '.MAIN_DB_PREFIX.'propal as p ON p.fk_soc = s.rowid';
603if (!empty($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
604 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (p.rowid = ef.fk_object)";
605}
606if ($search_all) {
607 $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'propaldet as pd ON p.rowid = pd.fk_propal';
608}
609$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'user as u ON p.fk_user_author = u.rowid';
610$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet as pr ON pr.rowid = p.fk_projet";
611$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_availability as ava on (ava.rowid = p.fk_availability)";
612// Add table from hooks
613$parameters = array();
614$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object); // Note that $action and $object may have been modified by hook
615$sql .= $hookmanager->resPrint;
616
617$sql .= ' WHERE';
618$sql .= ' p.entity IN ('.getEntity('propal').')';
619if ($search_town) {
620 $sql .= natural_search('s.town', $search_town);
621}
622if ($search_zip) {
623 $sql .= natural_search("s.zip", $search_zip);
624}
625if ($search_state) {
626 $sql .= natural_search("state.nom", $search_state);
627}
628if ($search_country) {
629 $sql .= " AND s.fk_pays IN (".$db->sanitize($db->escape($search_country)).')';
630}
631if ($search_type_thirdparty != '' && $search_type_thirdparty > 0) {
632 $sql .= " AND s.fk_typent IN (".$db->sanitize($db->escape($search_type_thirdparty)).')';
633}
634if ($search_ref) {
635 $sql .= natural_search('p.ref', $search_ref);
636}
637if ($search_refcustomer) {
638 $sql .= natural_search('p.ref_client', $search_refcustomer);
639}
640if ($search_refproject) {
641 $sql .= natural_search('pr.ref', $search_refproject);
642}
643if ($search_project) {
644 $sql .= natural_search('pr.title', $search_project);
645}
646if ($search_availability) {
647 $sql .= " AND p.fk_availability IN (".$db->sanitize($db->escape($search_availability)).')';
648}
649$societe_add_ref_in_list = getDolGlobalInt('SOCIETE_ADD_REF_IN_LIST');
650if (empty($arrayfields['s.name_alias']['checked']) && $search_societe) {
651 if ($societe_add_ref_in_list == 1) {
652 $sql .= natural_search(array("s.nom", "s.name_alias", "s.code_client"), $search_societe);
653 } else {
654 $sql .= natural_search(array("s.nom", "s.name_alias"), $search_societe);
655 }
656} else {
657 if ($search_societe) {
658 if ($societe_add_ref_in_list == 1) {
659 $sql .= natural_search(array('s.nom', 's.code_client'), $search_societe);
660 } else {
661 $sql .= natural_search('s.nom', $search_societe);
662 }
663 }
664 if ($search_societe_alias) {
665 $sql .= natural_search('s.name_alias', $search_societe_alias);
666 }
667}
668// Rechercher dans code_client si SOCIETE_ADD_REF_IN_LIST est égal à 1
669if ($societe_add_ref_in_list == 1 && $search_code_client && !$search_societe) {
670 $sql .= natural_search('s.code_client', $search_code_client);
671}
672if ($search_login) {
673 $sql .= natural_search(array("u.login", "u.firstname", "u.lastname"), $search_login);
674}
675if ($search_montant_ht != '') {
676 $sql .= natural_search("p.total_ht", $search_montant_ht, 1);
677}
678if ($search_montant_vat != '') {
679 $sql .= natural_search("p.total_tva", $search_montant_vat, 1);
680}
681if ($search_montant_ttc != '') {
682 $sql .= natural_search("p.total_ttc", $search_montant_ttc, 1);
683}
684if ($search_warehouse != '' && $search_warehouse > 0) {
685 $sql .= natural_search("p.fk_warehouse", $search_warehouse, 1);
686}
687if ($search_multicurrency_code != '') {
688 $sql .= " AND p.multicurrency_code = '".$db->escape($search_multicurrency_code)."'";
689}
690if ($search_multicurrency_tx != '') {
691 $sql .= natural_search('p.multicurrency_tx', $search_multicurrency_tx, 1);
692}
693if ($search_multicurrency_montant_ht != '') {
694 $sql .= natural_search('p.multicurrency_total_ht', $search_multicurrency_montant_ht, 1);
695}
696if ($search_multicurrency_montant_vat != '') {
697 $sql .= natural_search('p.multicurrency_total_tva', $search_multicurrency_montant_vat, 1);
698}
699if ($search_multicurrency_montant_ttc != '') {
700 $sql .= natural_search('p.multicurrency_total_ttc', $search_multicurrency_montant_ttc, 1);
701}
702if ($search_all) {
703 $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
704}
705if ($search_fk_cond_reglement > 0) {
706 $sql .= " AND p.fk_cond_reglement = ".((int) $search_fk_cond_reglement);
707}
708if ($search_fk_shipping_method > 0) {
709 $sql .= " AND p.fk_shipping_method = ".((int) $search_fk_shipping_method);
710}
711if ($search_fk_input_reason > 0) {
712 $sql .= " AND p.fk_input_reason = ".((int) $search_fk_input_reason);
713}
714if ($search_fk_mode_reglement > 0) {
715 $sql .= " AND p.fk_mode_reglement = ".((int) $search_fk_mode_reglement);
716}
717if ($socid > 0) {
718 $sql .= ' AND s.rowid = '.((int) $socid);
719}
720if ($search_status != '' && $search_status != '-1') {
721 $sql .= ' AND p.fk_statut IN ('.$db->sanitize($search_status).')';
722}
723if ($search_date_start) {
724 $sql .= " AND p.datep >= '".$db->idate($search_date_start)."'";
725}
726if ($search_date_end) {
727 $sql .= " AND p.datep <= '".$db->idate($search_date_end)."'";
728}
729if ($search_date_end_start) {
730 $sql .= " AND p.fin_validite >= '".$db->idate($search_date_end_start)."'";
731}
732if ($search_date_end_end) {
733 $sql .= " AND p.fin_validite <= '".$db->idate($search_date_end_end)."'";
734}
735if ($search_date_delivery_start) {
736 $sql .= " AND p.date_livraison >= '".$db->idate($search_date_delivery_start)."'";
737}
738if ($search_date_delivery_end) {
739 $sql .= " AND p.date_livraison <= '".$db->idate($search_date_delivery_end)."'";
740}
741if ($search_date_signature_start) {
742 $sql .= " AND p.date_signature >= '".$db->idate($search_date_signature_start)."'";
743}
744if ($search_date_signature_end) {
745 $sql .= " AND p.date_signature <= '".$db->idate($search_date_signature_end)."'";
746}
747if ($search_note_public) {
748 $sql .= " AND p.note_public LIKE '%".$db->escape($db->escapeforlike($search_note_public))."%'";
749}
750// Search on user
751if ($search_user > 0) {
752 $sql .= " AND EXISTS (";
753 $sql .= " SELECT ec.fk_c_type_contact, ec.element_id, ec.fk_socpeople";
754 $sql .= " FROM llx_element_contact as ec";
755 $sql .= " INNER JOIN llx_c_type_contact as tc";
756 $sql .= " ON ec.fk_c_type_contact = tc.rowid AND tc.element='propal' AND tc.source='internal'";
757 $sql .= " WHERE ec.element_id = p.rowid AND ec.fk_socpeople = ".((int) $search_user).")";
758}
759// Search on sale representative
760if ($search_sale && $search_sale != '-1') {
761 if ($search_sale == -2) {
762 $sql .= " AND NOT EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc WHERE sc.fk_soc = p.fk_soc)";
763 } elseif ($search_sale > 0) {
764 $sql .= " AND EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc WHERE sc.fk_soc = p.fk_soc AND sc.fk_user = ".((int) $search_sale).")";
765 }
766}
767// Search for tag/category ($searchCategoryCustomerList is an array of ID)
768$searchCategoryCustomerOperator = -1;
769$searchCategoryCustomerList = array($search_categ_cus);
770if (!empty($searchCategoryCustomerList)) {
771 $searchCategoryCustomerSqlList = array();
772 $listofcategoryid = '';
773 foreach ($searchCategoryCustomerList as $searchCategoryCustomer) {
774 if (intval($searchCategoryCustomer) == -2) {
775 $searchCategoryCustomerSqlList[] = "NOT EXISTS (SELECT cs.fk_soc FROM ".MAIN_DB_PREFIX."categorie_societe as cs WHERE s.rowid = cs.fk_soc)";
776 } elseif (intval($searchCategoryCustomer) > 0) {
777 if ($searchCategoryCustomerOperator == 0) {
778 $searchCategoryCustomerSqlList[] = " EXISTS (SELECT cs.fk_soc FROM ".MAIN_DB_PREFIX."categorie_societe as cs WHERE s.rowid = cs.fk_soc AND cs.fk_categorie = ".((int) $searchCategoryCustomer).")";
779 } else {
780 $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryCustomer);
781 }
782 }
783 }
784 if ($listofcategoryid) {
785 $searchCategoryCustomerSqlList[] = " EXISTS (SELECT cs.fk_soc FROM ".MAIN_DB_PREFIX."categorie_societe as cs WHERE s.rowid = cs.fk_soc AND cs.fk_categorie IN (".$db->sanitize($listofcategoryid)."))";
786 }
787 if ($searchCategoryCustomerOperator == 1) {
788 if (!empty($searchCategoryCustomerSqlList)) {
789 $sql .= " AND (".implode(' OR ', $searchCategoryCustomerSqlList).")";
790 }
791 } else {
792 if (!empty($searchCategoryCustomerSqlList)) {
793 $sql .= " AND (".implode(' AND ', $searchCategoryCustomerSqlList).")";
794 }
795 }
796}
797// Search for tag/category ($searchCategoryProductList is an array of ID)
798$searchCategoryProductOperator = -1;
799$searchCategoryProductList = array($search_product_category);
800if (!empty($searchCategoryProductList)) {
801 $searchCategoryProductSqlList = array();
802 $listofcategoryid = '';
803 foreach ($searchCategoryProductList as $searchCategoryProduct) {
804 if (intval($searchCategoryProduct) == -2) {
805 $searchCategoryProductSqlList[] = "NOT EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX."categorie_product as ck, ".MAIN_DB_PREFIX."propaldet as pd WHERE pd.fk_propal = p.rowid AND pd.fk_product = ck.fk_product)";
806 } elseif (intval($searchCategoryProduct) > 0) {
807 if ($searchCategoryProductOperator == 0) {
808 $searchCategoryProductSqlList[] = " EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX."categorie_product as ck, ".MAIN_DB_PREFIX."propaldet as pd WHERE pd.fk_propal = p.rowid AND pd.fk_product = ck.fk_product AND ck.fk_categorie = ".((int) $searchCategoryProduct).")";
809 } else {
810 $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryProduct);
811 }
812 }
813 }
814 if ($listofcategoryid) {
815 $searchCategoryProductSqlList[] = " EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX."categorie_product as ck, ".MAIN_DB_PREFIX."propaldet as pd WHERE pd.fk_propal = p.rowid AND pd.fk_product = ck.fk_product AND ck.fk_categorie IN (".$db->sanitize($listofcategoryid)."))";
816 }
817 if ($searchCategoryProductOperator == 1) {
818 if (!empty($searchCategoryProductSqlList)) {
819 $sql .= " AND (".implode(' OR ', $searchCategoryProductSqlList).")";
820 }
821 } else {
822 if (!empty($searchCategoryProductSqlList)) {
823 $sql .= " AND (".implode(' AND ', $searchCategoryProductSqlList).")";
824 }
825 }
826}
827if ($search_option == 'late') {
828 $sql .= " AND p.fin_validite < '".$db->idate(dol_now() - $conf->propal->cloture->warning_delay)."'";
829}
830// Add where from extra fields
831include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
832//print $sql;
833
834// Add where from hooks
835$parameters = array();
836$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
837$sql .= $hookmanager->resPrint;
838
839// Add HAVING from hooks
840$parameters = array();
841$reshook = $hookmanager->executeHooks('printFieldListHaving', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
842$sql .= empty($hookmanager->resPrint) ? "" : " HAVING 1=1 ".$hookmanager->resPrint;
843
844// Count total nb of records
845$nbtotalofrecords = '';
846if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
847 /* The fast and low memory method to get and count full list converts the sql into a sql count */
848 $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql);
849 $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount);
850 $resql = $db->query($sqlforcount);
851 if ($resql) {
852 $objforcount = $db->fetch_object($resql);
853 $nbtotalofrecords = $objforcount->nbtotalofrecords;
854 } else {
855 dol_print_error($db);
856 }
857
858 if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
859 $page = 0;
860 $offset = 0;
861 }
862 $db->free($resql);
863}
864
865// Complete request and execute it with limit
866$sql .= $db->order($sortfield, $sortorder);
867$sql .= ', p.ref DESC';
868if ($limit) {
869 $sql .= $db->plimit($limit + 1, $offset);
870}
871
872$resql = $db->query($sql);
873if (!$resql) {
874 dol_print_error($db);
875 exit;
876}
877
878$objectstatic = new Propal($db);
879$userstatic = new User($db);
880
881if ($socid > 0) {
882 $soc = new Societe($db);
883 $soc->fetch($socid);
884 $title = $langs->trans('Proposals').' - '.$soc->name;
885 if (empty($search_societe)) {
886 $search_societe = $soc->name;
887 }
888} else {
889 $title = $langs->trans('Proposals');
890}
891
892$num = $db->num_rows($resql);
893
894$arrayofselected = is_array($toselect) ? $toselect : array();
895
896if ($num == 1 && getDolGlobalString('MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all) {
897 $obj = $db->fetch_object($resql);
898
899 $id = $obj->rowid;
900
901 header("Location: ".DOL_URL_ROOT.'/comm/propal/card.php?id='.$id);
902 exit;
903}
904
905$help_url = 'EN:Commercial_Proposals|FR:Proposition_commerciale|ES:Presupuestos';
906llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'bodyforlist');
907
908$param = '&search_status='.urlencode($search_status);
909if (!empty($mode)) {
910 $param .= '&mode='.urlencode($mode);
911}
912if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
913 $param .= '&contextpage='.urlencode($contextpage);
914}
915if ($limit > 0 && $limit != $conf->liste_limit) {
916 $param .= '&limit='.((int) $limit);
917}
918if ($search_all) {
919 $param .= '&search_all='.urlencode($search_all);
920}
921if ($search_date_startday) {
922 $param .= '&search_date_startday='.urlencode((string) ($search_date_startday));
923}
924if ($search_date_startmonth) {
925 $param .= '&search_date_startmonth='.urlencode((string) ($search_date_startmonth));
926}
927if ($search_date_startyear) {
928 $param .= '&search_date_startyear='.urlencode((string) ($search_date_startyear));
929}
930if ($search_date_endday) {
931 $param .= '&search_date_endday='.urlencode((string) ($search_date_endday));
932}
933if ($search_date_endmonth) {
934 $param .= '&search_date_endmonth='.urlencode((string) ($search_date_endmonth));
935}
936if ($search_date_endyear) {
937 $param .= '&search_date_endyear='.urlencode((string) ($search_date_endyear));
938}
939if ($search_date_end_startday) {
940 $param .= '&search_date_end_startday='.urlencode((string) ($search_date_end_startday));
941}
942if ($search_date_end_startmonth) {
943 $param .= '&search_date_end_startmonth='.urlencode((string) ($search_date_end_startmonth));
944}
945if ($search_date_end_startyear) {
946 $param .= '&search_date_end_startyear='.urlencode((string) ($search_date_end_startyear));
947}
948if ($search_date_end_endday) {
949 $param .= '&search_date_end_endday='.urlencode((string) ($search_date_end_endday));
950}
951if ($search_date_end_endmonth) {
952 $param .= '&search_date_end_endmonth='.urlencode((string) ($search_date_end_endmonth));
953}
954if ($search_date_end_endyear) {
955 $param .= '&search_date_end_endyear='.urlencode((string) ($search_date_end_endyear));
956}
957if ($search_date_delivery_startday) {
958 $param .= '&search_date_delivery_startday='.urlencode((string) ($search_date_delivery_startday));
959}
960if ($search_date_delivery_startmonth) {
961 $param .= '&search_date_delivery_startmonth='.urlencode((string) ($search_date_delivery_startmonth));
962}
963if ($search_date_delivery_startyear) {
964 $param .= '&search_date_delivery_startyear='.urlencode((string) ($search_date_delivery_startyear));
965}
966if ($search_date_delivery_endday) {
967 $param .= '&search_date_delivery_endday='.urlencode((string) ($search_date_delivery_endday));
968}
969if ($search_date_delivery_endmonth) {
970 $param .= '&search_date_delivery_endmonth='.urlencode((string) ($search_date_delivery_endmonth));
971}
972if ($search_date_delivery_endyear) {
973 $param .= '&search_date_delivery_endyear='.urlencode((string) ($search_date_delivery_endyear));
974}
975if ($search_ref) {
976 $param .= '&search_ref='.urlencode($search_ref);
977}
978if ($search_refcustomer) {
979 $param .= '&search_refcustomer='.urlencode($search_refcustomer);
980}
981if ($search_refproject) {
982 $param .= '&search_refproject='.urlencode($search_refproject);
983}
984if ($search_societe) {
985 $param .= '&search_societe='.urlencode($search_societe);
986}
987if ($search_societe_alias) {
988 $param .= '&search_societe_alias='.urlencode($search_societe_alias);
989}
990if ($search_user > 0) {
991 $param .= '&search_user='.urlencode((string) ($search_user));
992}
993if ($search_sale > 0) {
994 $param .= '&search_sale='.urlencode((string) $search_sale);
995}
996if ($search_montant_ht) {
997 $param .= '&search_montant_ht='.urlencode($search_montant_ht);
998}
999if ($search_multicurrency_code != '') {
1000 $param .= '&search_multicurrency_code='.urlencode($search_multicurrency_code);
1001}
1002if ($search_multicurrency_tx != '') {
1003 $param .= '&search_multicurrency_tx='.urlencode($search_multicurrency_tx);
1004}
1005if ($search_multicurrency_montant_ht != '') {
1006 $param .= '&search_multicurrency_montant_ht='.urlencode($search_multicurrency_montant_ht);
1007}
1008if ($search_multicurrency_montant_vat != '') {
1009 $param .= '&search_multicurrency_montant_vat='.urlencode($search_multicurrency_montant_vat);
1010}
1011if ($search_multicurrency_montant_ttc != '') {
1012 $param .= '&search_multicurrency_montant_ttc='.urlencode($search_multicurrency_montant_ttc);
1013}
1014if ($search_login) {
1015 $param .= '&search_login='.urlencode($search_login);
1016}
1017if ($search_town) {
1018 $param .= '&search_town='.urlencode($search_town);
1019}
1020if ($search_zip) {
1021 $param .= '&search_zip='.urlencode($search_zip);
1022}
1023if ($socid > 0) {
1024 $param .= '&socid='.urlencode((string) ($socid));
1025}
1026if ($optioncss != '') {
1027 $param .= '&optioncss='.urlencode($optioncss);
1028}
1029if ($search_categ_cus > 0) {
1030 $param .= '&search_categ_cus='.urlencode((string) ($search_categ_cus));
1031}
1032if ($search_product_category != '') {
1033 $param .= '&search_product_category='.urlencode((string) ($search_product_category));
1034}
1035if ($search_fk_cond_reglement > 0) {
1036 $param .= '&search_fk_cond_reglement='.urlencode((string) ($search_fk_cond_reglement));
1037}
1038if ($search_fk_shipping_method > 0) {
1039 $param .= '&search_fk_shipping_method='.urlencode((string) ($search_fk_shipping_method));
1040}
1041if ($search_fk_input_reason > 0) {
1042 $param .= '&search_fk_input_reason='.urlencode((string) ($search_fk_input_reason));
1043}
1044if ($search_fk_mode_reglement > 0) {
1045 $param .= '&search_fk_mode_reglement='.urlencode((string) ($search_fk_mode_reglement));
1046}
1047if ($search_type_thirdparty > 0) {
1048 $param .= '&search_type_thirdparty='.urlencode((string) ($search_type_thirdparty));
1049}
1050if ($search_town) {
1051 $param .= '&search_town='.urlencode($search_town);
1052}
1053if ($search_zip) {
1054 $param .= '&search_zip='.urlencode($search_zip);
1055}
1056if ($search_state) {
1057 $param .= '&search_state='.urlencode($search_state);
1058}
1059if ($search_town) {
1060 $param .= '&search_town='.urlencode($search_town);
1061}
1062if ($search_country) {
1063 $param .= '&search_country='.urlencode((string) ($search_country));
1064}
1065if ($search_date_signature_startday) {
1066 $param .= '&search_date_signature_startday='.urlencode((string) ($search_date_signature_startday));
1067}
1068if ($search_date_signature_startmonth) {
1069 $param .= '&search_date_signature_startmonth='.urlencode((string) ($search_date_signature_startmonth));
1070}
1071if ($search_date_signature_startyear) {
1072 $param .= '&search_date_signature_startyear='.urlencode((string) ($search_date_signature_startyear));
1073}
1074if ($search_date_signature_endday) {
1075 $param .= '&search_date_signature_endday='.urlencode((string) ($search_date_signature_endday));
1076}
1077if ($search_date_signature_endmonth) {
1078 $param .= '&search_date_signature_endmonth='.urlencode((string) ($search_date_signature_endmonth));
1079}
1080if ($search_date_signature_endyear) {
1081 $param .= '&search_date_signature_endyear='.urlencode((string) ($search_date_signature_endyear));
1082}
1083
1084// Add $param from extra fields
1085include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
1086// Add $param from hooks
1087$parameters = array('param' => &$param);
1088$reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1089$param .= $hookmanager->resPrint;
1090
1091// List of mass actions available
1092$arrayofmassactions = array(
1093 'generate_doc' => img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("ReGeneratePDF"),
1094 'builddoc' => img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
1095);
1096if ($permissiontosendbymail) {
1097 $arrayofmassactions['presend'] = img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail");
1098}
1099if ($permissiontovalidate) {
1100 $arrayofmassactions['prevalidate'] = img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("Validate");
1101}
1102if ($permissiontoclose) {
1103 $arrayofmassactions['presign'] = img_picto('', 'propal', 'class="pictofixedwidth"').$langs->trans("Sign");
1104 $arrayofmassactions['nopresign'] = img_picto('', 'propal', 'class="pictofixedwidth"').$langs->trans("NoSign");
1105 $arrayofmassactions['setbilled'] = img_picto('', 'bill', 'class="pictofixedwidth"').$langs->trans("ClassifyBilled");
1106}
1107if ($permissiontodelete) {
1108 $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
1109}
1110
1111if (in_array($massaction, array('presend', 'predelete', 'closed'))) {
1112 $arrayofmassactions = array();
1113}
1114$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
1115
1116$url = DOL_URL_ROOT.'/comm/propal/card.php?action=create';
1117if (!empty($socid)) {
1118 $url .= '&socid='.$socid;
1119}
1120$newcardbutton = '';
1121$newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss' => 'reposition'));
1122$newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss' => 'reposition'));
1123$newcardbutton .= dolGetButtonTitleSeparator();
1124$newcardbutton .= dolGetButtonTitle($langs->trans('NewPropal'), '', 'fa fa-plus-circle', $url, '', $user->hasRight('propal', 'creer'));
1125
1126// Fields title search
1127print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
1128if ($optioncss != '') {
1129 print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
1130}
1131print '<input type="hidden" name="token" value="'.newToken().'">';
1132print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
1133print '<input type="hidden" name="action" value="list">';
1134print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
1135print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
1136print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
1137print '<input type="hidden" name="socid" value="'.$socid.'">';
1138print '<input type="hidden" name="mode"value="'.$mode.'">';
1139
1140print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'propal', 0, $newcardbutton, '', $limit, 0, 0, 1);
1141
1142$topicmail = "SendPropalRef";
1143$modelmail = "propal_send";
1144$objecttmp = new Propal($db);
1145$trackid = 'pro'.$object->id;
1146include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
1147
1148if ($massaction == 'prevalidate') {
1149 print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmMassValidation"), $langs->trans("ConfirmMassValidationQuestion"), "validate", null, '', 0, 200, 500, 1);
1150}
1151
1152if ($massaction == 'presign') {
1153 print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmMassSignature"), $langs->trans("ConfirmMassSignatureQuestion"), "sign", null, '', 0, 200, 500, 1);
1154}
1155
1156if ($massaction == 'nopresign') {
1157 print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmMassNoSignature"), $langs->trans("ConfirmMassNoSignatureQuestion"), "nosign", null, '', 0, 200, 500, 1);
1158}
1159
1160if ($search_all) {
1161 foreach ($fieldstosearchall as $key => $val) {
1162 $fieldstosearchall[$key] = $langs->trans($val);
1163 }
1164 print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).implode(', ', $fieldstosearchall).'</div>';
1165}
1166
1167$i = 0;
1168
1169$moreforfilter = '';
1170
1171// If the user can view prospects other than his'
1172if ($user->hasRight('user', 'user', 'lire')) {
1173 $langs->load("commercial");
1174 $moreforfilter .= '<div class="divsearchfield">';
1175 $tmptitle = $langs->trans('ThirdPartiesOfSaleRepresentative');
1176 $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, $tmptitle, 'maxwidth250 widthcentpercentminusx', 1);
1177 $moreforfilter .= '</div>';
1178}
1179// If the user can view prospects other than his'
1180if ($user->hasRight('user', 'user', 'lire')) {
1181 $moreforfilter .= '<div class="divsearchfield">';
1182 $tmptitle = $langs->trans('LinkedToSpecificUsers');
1183 $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$form->select_dolusers((empty($search_user) ? -2 : 0), 'search_user', $tmptitle, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth250 widthcentpercentminusx');
1184 $moreforfilter .= '</div>';
1185}
1186// If the user can view products
1187if (isModEnabled('category') && $user->hasRight('categorie', 'read') && ($user->hasRight('product', 'read') || $user->hasRight('service', 'read'))) {
1188 $searchCategoryProductOperator = -1;
1189 include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
1190 $tmptitle = $langs->trans('IncludingProductWithTag');
1191 $formcategory = new FormCategory($db);
1192 $moreforfilter .= $formcategory->getFilterBox(Categorie::TYPE_PRODUCT, array($search_product_category), 'maxwidth300', $searchCategoryProductOperator, 0, 0, $tmptitle);
1193}
1194if (isModEnabled('category') && $user->hasRight('categorie', 'lire')) {
1195 require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
1196 $moreforfilter .= '<div class="divsearchfield">';
1197 $tmptitle = $langs->trans('CustomersProspectsCategoriesShort');
1198 $moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"').$formother->select_categories('customer', $search_categ_cus, 'search_categ_cus', 1, $tmptitle, (empty($conf->dol_optimize_smallscreen) ? 'maxwidth300 widthcentpercentminusx' : 'maxwidth250 widthcentpercentminusx'));
1199 $moreforfilter .= '</div>';
1200}
1201if (isModEnabled('stock') && getDolGlobalString('WAREHOUSE_ASK_WAREHOUSE_DURING_PROPAL')) {
1202 require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
1203 $formproduct = new FormProduct($db);
1204 $moreforfilter .= '<div class="divsearchfield">';
1205 $tmptitle = $langs->trans('Warehouse');
1206 $moreforfilter .= img_picto($tmptitle, 'stock', 'class="pictofixedwidth"').$formproduct->selectWarehouses($search_warehouse, 'search_warehouse', '', $tmptitle, 0, 0, $tmptitle);
1207 $moreforfilter .= '</div>';
1208}
1209$parameters = array();
1210$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1211if (empty($reshook)) {
1212 $moreforfilter .= $hookmanager->resPrint;
1213} else {
1214 $moreforfilter = $hookmanager->resPrint;
1215}
1216
1217if (!empty($moreforfilter)) {
1218 print '<div class="liste_titre liste_titre_bydiv centpercent">';
1219 print $moreforfilter;
1220 print '</div>';
1221}
1222
1223$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
1224$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')); // This also change content of $arrayfields
1225$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
1226
1227print '<div class="div-table-responsive">';
1228print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
1229
1230print '<tr class="liste_titre_filter">';
1231
1232// Action column
1233if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1234 print '<td class="liste_titre" align="middle">';
1235 $searchpicto = $form->showFilterButtons('left');
1236 print $searchpicto;
1237 print '</td>';
1238}
1239
1240if (!empty($arrayfields['p.ref']['checked'])) {
1241 print '<td class="liste_titre">';
1242 print '<input class="flat maxwidth50" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
1243 print '</td>';
1244}
1245if (!empty($arrayfields['p.ref_client']['checked'])) {
1246 print '<td class="liste_titre">';
1247 print '<input class="flat maxwidth50" type="text" name="search_refcustomer" value="'.dol_escape_htmltag($search_refcustomer).'">';
1248 print '</td>';
1249}
1250if (!empty($arrayfields['pr.ref']['checked'])) {
1251 print '<td class="liste_titre">';
1252 print '<input class="flat maxwidth50" type="text" name="search_refproject" value="'.dol_escape_htmltag($search_refproject).'">';
1253 print '</td>';
1254}
1255if (!empty($arrayfields['pr.title']['checked'])) {
1256 print '<td class="liste_titre">';
1257 print '<input class="flat maxwidth50" type="text" name="search_project" value="'.dol_escape_htmltag($search_project).'">';
1258 print '</td>';
1259}
1260if (!empty($arrayfields['s.nom']['checked'])) {
1261 print '<td class="liste_titre" align="left">';
1262 print '<input class="flat maxwidth100" type="text" name="search_societe" value="'.dol_escape_htmltag($search_societe).'"'.($socid > 0 ? " disabled" : "").'>';
1263 print '</td>';
1264}
1265if (!empty($arrayfields['s.name_alias']['checked'])) {
1266 print '<td class="liste_titre" align="left">';
1267 print '<input class="flat maxwidth100" type="text" name="search_societe_alias" value="'.dol_escape_htmltag($search_societe_alias).'">';
1268 print '</td>';
1269}
1270if (!empty($arrayfields['s.town']['checked'])) {
1271 print '<td class="liste_titre"><input class="flat maxwidth50" type="text" name="search_town" value="'.$search_town.'"></td>';
1272}
1273if (!empty($arrayfields['s.zip']['checked'])) {
1274 print '<td class="liste_titre"><input class="flat maxwidth50" type="text" name="search_zip" value="'.$search_zip.'"></td>';
1275}
1276// State
1277if (!empty($arrayfields['state.nom']['checked'])) {
1278 print '<td class="liste_titre">';
1279 print '<input class="flat maxwidth50" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).'">';
1280 print '</td>';
1281}
1282// Country
1283if (!empty($arrayfields['country.code_iso']['checked'])) {
1284 print '<td class="liste_titre" align="center">';
1285 print $form->select_country($search_country, 'search_country', '', 0, 'minwidth100imp maxwidth100');
1286 print '</td>';
1287}
1288// Company type
1289if (!empty($arrayfields['typent.code']['checked'])) {
1290 print '<td class="liste_titre maxwidth100onsmartphone" align="center">';
1291 print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 1, 0, 0, '', 0, 0, 0, getDolGlobalString('SOCIETE_SORT_ON_TYPEENT', 'ASC'), 'maxwidth100', 1);
1292 print ajax_combobox('search_type_thirdparty');
1293 print '</td>';
1294}
1295// Date
1296if (!empty($arrayfields['p.date']['checked'])) {
1297 print '<td class="liste_titre center">';
1298 print '<div class="nowrapfordate">';
1299 print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
1300 print '</div>';
1301 print '<div class="nowrapfordate">';
1302 print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
1303 print '</div>';
1304 print '</td>';
1305}
1306// Date end
1307if (!empty($arrayfields['p.fin_validite']['checked'])) {
1308 print '<td class="liste_titre center">';
1309 print '<div class="nowrapfordate">';
1310 print $form->selectDate($search_date_end_start ? $search_date_end_start : -1, 'search_date_end_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
1311 print '</div>';
1312 print '<div class="nowrapfordate">';
1313 print $form->selectDate($search_date_end_end ? $search_date_end_end : -1, 'search_date_end_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
1314 print '</div>';
1315 print '</td>';
1316}
1317// Date delivery
1318if (!empty($arrayfields['p.date_livraison']['checked'])) {
1319 print '<td class="liste_titre center">';
1320 print '<div class="nowrapfordate">';
1321 print $form->selectDate($search_date_delivery_start ? $search_date_delivery_start : -1, 'search_date_delivery_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
1322 print '</div>';
1323 print '<div class="nowrapfordate">';
1324 print $form->selectDate($search_date_delivery_end ? $search_date_delivery_end : -1, 'search_date_delivery_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
1325 print '</div>';
1326 print '</td>';
1327}
1328// Date Signature
1329if (!empty($arrayfields['p.date_signature']['checked'])) {
1330 print '<td class="liste_titre center">';
1331 print '<div class="nowrapfordate">';
1332 print $form->selectDate($search_date_signature_start ? $search_date_signature_start : -1, 'search_date_signature_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
1333 print '</div>';
1334 print '<div class="nowrapfordate">';
1335 print $form->selectDate($search_date_signature_end ? $search_date_signature_end : -1, 'search_date_signature_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
1336 print '</div>';
1337 print '</td>';
1338}
1339// Availability
1340if (!empty($arrayfields['ava.rowid']['checked'])) {
1341 print '<td class="liste_titre maxwidth100onsmartphone center">';
1342 $form->selectAvailabilityDelay($search_availability, 'search_availability', '', 1);
1343 print ajax_combobox('search_availability');
1344 print '</td>';
1345}
1346// Shipping Method
1347if (!empty($arrayfields['p.fk_shipping_method']['checked'])) {
1348 print '<td class="liste_titre">';
1349 $form->selectShippingMethod($search_fk_shipping_method, 'search_fk_shipping_method', '', 1, '', 1);
1350 print '</td>';
1351}
1352// Source - Input reason
1353if (!empty($arrayfields['p.fk_input_reason']['checked'])) {
1354 print '<td class="liste_titre">';
1355 $form->selectInputReason($search_fk_input_reason, 'search_fk_input_reason', '', 1, 'maxwidth125', 1);
1356 print '</td>';
1357}
1358// Payment term
1359if (!empty($arrayfields['p.fk_cond_reglement']['checked'])) {
1360 print '<td class="liste_titre">';
1361 print $form->getSelectConditionsPaiements($search_fk_cond_reglement, 'search_fk_cond_reglement', 1, 1, 1);
1362 print '</td>';
1363}
1364// Payment mode
1365if (!empty($arrayfields['p.fk_mode_reglement']['checked'])) {
1366 print '<td class="liste_titre">';
1367 print $form->select_types_paiements($search_fk_mode_reglement, 'search_fk_mode_reglement', '', 0, 1, 1, 0, -1, '', 1);
1368 print '</td>';
1369}
1370if (!empty($arrayfields['p.total_ht']['checked'])) {
1371 // Amount
1372 print '<td class="liste_titre right">';
1373 print '<input class="flat" type="text" size="5" name="search_montant_ht" value="'.dol_escape_htmltag($search_montant_ht).'">';
1374 print '</td>';
1375}
1376if (!empty($arrayfields['p.total_tva']['checked'])) {
1377 // Amount
1378 print '<td class="liste_titre right">';
1379 print '<input class="flat" type="text" size="5" name="search_montant_vat" value="'.dol_escape_htmltag($search_montant_vat).'">';
1380 print '</td>';
1381}
1382if (!empty($arrayfields['p.total_ttc']['checked'])) {
1383 // Amount
1384 print '<td class="liste_titre right">';
1385 print '<input class="flat" type="text" size="5" name="search_montant_ttc" value="'.dol_escape_htmltag($search_montant_ttc).'">';
1386 print '</td>';
1387}
1388if (!empty($arrayfields['p.total_ht_invoiced']['checked'])) {
1389 // Amount invoiced
1390 print '<td class="liste_titre right">';
1391 print '</td>';
1392}
1393if (!empty($arrayfields['p.total_invoiced']['checked'])) {
1394 // Amount invoiced
1395 print '<td class="liste_titre right">';
1396 print '</td>';
1397}
1398if (!empty($arrayfields['p.multicurrency_code']['checked'])) {
1399 // Currency
1400 print '<td class="liste_titre">';
1401 print $form->selectMultiCurrency($search_multicurrency_code, 'search_multicurrency_code', 1);
1402 print '</td>';
1403}
1404if (!empty($arrayfields['p.multicurrency_tx']['checked'])) {
1405 // Currency rate
1406 print '<td class="liste_titre">';
1407 print '<input class="flat" type="text" size="4" name="search_multicurrency_tx" value="'.dol_escape_htmltag($search_multicurrency_tx).'">';
1408 print '</td>';
1409}
1410if (!empty($arrayfields['p.multicurrency_total_ht']['checked'])) {
1411 // Amount
1412 print '<td class="liste_titre right">';
1413 print '<input class="flat" type="text" size="4" name="search_multicurrency_montant_ht" value="'.dol_escape_htmltag($search_multicurrency_montant_ht).'">';
1414 print '</td>';
1415}
1416if (!empty($arrayfields['p.multicurrency_total_tva']['checked'])) {
1417 // Amount
1418 print '<td class="liste_titre right">';
1419 print '<input class="flat" type="text" size="4" name="search_multicurrency_montant_vat" value="'.dol_escape_htmltag($search_multicurrency_montant_vat).'">';
1420 print '</td>';
1421}
1422if (!empty($arrayfields['p.multicurrency_total_ttc']['checked'])) {
1423 // Amount
1424 print '<td class="liste_titre right">';
1425 print '<input class="flat" type="text" size="4" name="search_multicurrency_montant_ttc" value="'.dol_escape_htmltag($search_multicurrency_montant_ttc).'">';
1426 print '</td>';
1427}
1428if (!empty($arrayfields['p.multicurrency_total_ht_invoiced']['checked'])) {
1429 // Amount invoiced
1430 print '<td class="liste_titre right">';
1431 print '</td>';
1432}
1433if (!empty($arrayfields['p.multicurrency_total_invoiced']['checked'])) {
1434 // Amount invoiced
1435 print '<td class="liste_titre right">';
1436 print '</td>';
1437}
1438if (!empty($arrayfields['u.login']['checked'])) {
1439 // Author
1440 print '<td class="liste_titre">';
1441 print '<input class="flat maxwidth75" type="text" name="search_login" value="'.dol_escape_htmltag($search_login).'">';
1442 print '</td>';
1443}
1444if (!empty($arrayfields['sale_representative']['checked'])) {
1445 print '<td class="liste_titre"></td>';
1446}
1447if (!empty($arrayfields['total_pa']['checked'])) {
1448 print '<td class="liste_titre right">';
1449 print '</td>';
1450}
1451if (!empty($arrayfields['total_margin']['checked'])) {
1452 print '<td class="liste_titre right">';
1453 print '</td>';
1454}
1455if (!empty($arrayfields['total_margin_rate']['checked'])) {
1456 print '<td class="liste_titre right">';
1457 print '</td>';
1458}
1459if (!empty($arrayfields['total_mark_rate']['checked'])) {
1460 print '<td class="liste_titre right">';
1461 print '</td>';
1462}
1463// Extra fields
1464include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
1465
1466// Fields from hook
1467$parameters = array('arrayfields' => $arrayfields);
1468$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1469print $hookmanager->resPrint;
1470// Date creation
1471if (!empty($arrayfields['p.datec']['checked'])) {
1472 print '<td class="liste_titre">';
1473 print '</td>';
1474}
1475// Date modification
1476if (!empty($arrayfields['p.tms']['checked'])) {
1477 print '<td class="liste_titre">';
1478 print '</td>';
1479}
1480// Date cloture
1481if (!empty($arrayfields['p.date_cloture']['checked'])) {
1482 print '<td class="liste_titre">';
1483 print '</td>';
1484}
1485if (!empty($arrayfields['p.note_public']['checked'])) {
1486 // Note public
1487 print '<td class="liste_titre">';
1488 print '<input class="flat maxwidth75" type="text" name="search_note_public" value="'.dol_escape_htmltag($search_note_public).'">';
1489 print '</td>';
1490}
1491if (!empty($arrayfields['p.note_private']['checked'])) {
1492 // Note private
1493 print '<td class="liste_titre">';
1494 print '</td>';
1495}
1496// Status
1497if (!empty($arrayfields['p.fk_statut']['checked'])) {
1498 print '<td class="liste_titre center parentonrightofpage">';
1499 $formpropal->selectProposalStatus($search_status, 1, 0, 1, 'customer', 'search_status', 'search_status width100 onrightofpage');
1500 print '</td>';
1501}
1502// Action column
1503if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1504 print '<td class="liste_titre" align="middle">';
1505 $searchpicto = $form->showFilterButtons();
1506 print $searchpicto;
1507 print '</td>';
1508}
1509print "</tr>\n";
1510
1511$totalarray = array(
1512 'nbfield' => 0,
1513 'val' => array(
1514 'p.total_ht' => 0,
1515 'p.total_tva' => 0,
1516 'p.total_ttc' => 0,
1517 ),
1518);
1519
1520// Fields title
1521print '<tr class="liste_titre">';
1522if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1523 print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ');
1524 $totalarray['nbfield']++;
1525}
1526if (!empty($arrayfields['p.ref']['checked'])) {
1527 print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], 'p.ref', '', $param, '', $sortfield, $sortorder);
1528 $totalarray['nbfield']++;
1529}
1530if (!empty($arrayfields['p.ref_client']['checked'])) {
1531 print_liste_field_titre($arrayfields['p.ref_client']['label'], $_SERVER["PHP_SELF"], 'p.ref_client', '', $param, '', $sortfield, $sortorder);
1532 $totalarray['nbfield']++;
1533}
1534if (!empty($arrayfields['pr.ref']['checked'])) {
1535 print_liste_field_titre($arrayfields['pr.ref']['label'], $_SERVER["PHP_SELF"], 'pr.ref', '', $param, '', $sortfield, $sortorder);
1536 $totalarray['nbfield']++;
1537}
1538if (!empty($arrayfields['pr.title']['checked'])) {
1539 print_liste_field_titre($arrayfields['pr.title']['label'], $_SERVER["PHP_SELF"], 'pr.title', '', $param, '', $sortfield, $sortorder);
1540 $totalarray['nbfield']++;
1541}
1542if (!empty($arrayfields['s.nom']['checked'])) {
1543 print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], 's.nom', '', $param, '', $sortfield, $sortorder);
1544 $totalarray['nbfield']++;
1545}
1546if (!empty($arrayfields['s.name_alias']['checked'])) {
1547 print_liste_field_titre($arrayfields['s.name_alias']['label'], $_SERVER["PHP_SELF"], 's.name_alias', '', $param, '', $sortfield, $sortorder);
1548 $totalarray['nbfield']++;
1549}
1550if (!empty($arrayfields['s.town']['checked'])) {
1551 print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], 's.town', '', $param, '', $sortfield, $sortorder);
1552 $totalarray['nbfield']++;
1553}
1554if (!empty($arrayfields['s.zip']['checked'])) {
1555 print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], 's.zip', '', $param, '', $sortfield, $sortorder);
1556 $totalarray['nbfield']++;
1557}
1558if (!empty($arrayfields['state.nom']['checked'])) {
1559 print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder);
1560 $totalarray['nbfield']++;
1561}
1562if (!empty($arrayfields['country.code_iso']['checked'])) {
1563 print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, '', $sortfield, $sortorder, 'center ');
1564 $totalarray['nbfield']++;
1565}
1566if (!empty($arrayfields['typent.code']['checked'])) {
1567 print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, '', $sortfield, $sortorder, 'center ');
1568 $totalarray['nbfield']++;
1569}
1570if (!empty($arrayfields['p.date']['checked'])) {
1571 print_liste_field_titre($arrayfields['p.date']['label'], $_SERVER["PHP_SELF"], 'p.datep', '', $param, '', $sortfield, $sortorder, 'center ');
1572 $totalarray['nbfield']++;
1573}
1574if (!empty($arrayfields['p.fin_validite']['checked'])) {
1575 print_liste_field_titre($arrayfields['p.fin_validite']['label'], $_SERVER["PHP_SELF"], 'dfv', '', $param, '', $sortfield, $sortorder, 'center ');
1576 $totalarray['nbfield']++;
1577}
1578if (!empty($arrayfields['p.date_livraison']['checked'])) {
1579 print_liste_field_titre($arrayfields['p.date_livraison']['label'], $_SERVER["PHP_SELF"], 'p.date_livraison', '', $param, '', $sortfield, $sortorder, 'center ');
1580 $totalarray['nbfield']++;
1581}
1582if (!empty($arrayfields['p.date_signature']['checked'])) {
1583 print_liste_field_titre($arrayfields['p.date_signature']['label'], $_SERVER["PHP_SELF"], 'p.date_signature', '', $param, '', $sortfield, $sortorder, 'center ');
1584 $totalarray['nbfield']++;
1585}
1586if (!empty($arrayfields['ava.rowid']['checked'])) {
1587 print_liste_field_titre($arrayfields['ava.rowid']['label'], $_SERVER["PHP_SELF"], 'availability', '', $param, '', $sortfield, $sortorder);
1588 $totalarray['nbfield']++;
1589}
1590if (!empty($arrayfields['p.fk_shipping_method']['checked'])) {
1591 print_liste_field_titre($arrayfields['p.fk_shipping_method']['label'], $_SERVER["PHP_SELF"], "p.fk_shipping_method", "", $param, '', $sortfield, $sortorder);
1592 $totalarray['nbfield']++;
1593}
1594if (!empty($arrayfields['p.fk_input_reason']['checked'])) {
1595 print_liste_field_titre($arrayfields['p.fk_input_reason']['label'], $_SERVER["PHP_SELF"], "p.fk_input_reason", "", $param, '', $sortfield, $sortorder);
1596 $totalarray['nbfield']++;
1597}
1598if (!empty($arrayfields['p.fk_cond_reglement']['checked'])) {
1599 print_liste_field_titre($arrayfields['p.fk_cond_reglement']['label'], $_SERVER["PHP_SELF"], "p.fk_cond_reglement", "", $param, '', $sortfield, $sortorder);
1600 $totalarray['nbfield']++;
1601}
1602if (!empty($arrayfields['p.fk_mode_reglement']['checked'])) {
1603 print_liste_field_titre($arrayfields['p.fk_mode_reglement']['label'], $_SERVER["PHP_SELF"], "p.fk_mode_reglement", "", $param, '', $sortfield, $sortorder);
1604 $totalarray['nbfield']++;
1605}
1606if (!empty($arrayfields['p.total_ht']['checked'])) {
1607 print_liste_field_titre($arrayfields['p.total_ht']['label'], $_SERVER["PHP_SELF"], 'p.total_ht', '', $param, '', $sortfield, $sortorder, 'right ');
1608 $totalarray['nbfield']++;
1609}
1610if (!empty($arrayfields['p.total_tva']['checked'])) {
1611 print_liste_field_titre($arrayfields['p.total_tva']['label'], $_SERVER["PHP_SELF"], 'p.total_tva', '', $param, '', $sortfield, $sortorder, 'right ');
1612 $totalarray['nbfield']++;
1613}
1614if (!empty($arrayfields['p.total_ttc']['checked'])) {
1615 print_liste_field_titre($arrayfields['p.total_ttc']['label'], $_SERVER["PHP_SELF"], 'p.total_ttc', '', $param, '', $sortfield, $sortorder, 'right ');
1616 $totalarray['nbfield']++;
1617}
1618if (!empty($arrayfields['p.total_ht_invoiced']['checked'])) {
1619 print_liste_field_titre($arrayfields['p.total_ht_invoiced']['label'], $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right ');
1620 $totalarray['nbfield']++;
1621}
1622if (!empty($arrayfields['p.total_invoiced']['checked'])) {
1623 print_liste_field_titre($arrayfields['p.total_invoiced']['label'], $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right ');
1624 $totalarray['nbfield']++;
1625}
1626if (!empty($arrayfields['p.multicurrency_code']['checked'])) {
1627 print_liste_field_titre($arrayfields['p.multicurrency_code']['label'], $_SERVER['PHP_SELF'], 'p.multicurrency_code', '', $param, '', $sortfield, $sortorder);
1628 $totalarray['nbfield']++;
1629}
1630if (!empty($arrayfields['p.multicurrency_tx']['checked'])) {
1631 print_liste_field_titre($arrayfields['p.multicurrency_tx']['label'], $_SERVER['PHP_SELF'], 'p.multicurrency_tx', '', $param, '', $sortfield, $sortorder);
1632 $totalarray['nbfield']++;
1633}
1634if (!empty($arrayfields['p.multicurrency_total_ht']['checked'])) {
1635 print_liste_field_titre($arrayfields['p.multicurrency_total_ht']['label'], $_SERVER['PHP_SELF'], 'p.multicurrency_total_ht', '', $param, '', $sortfield, $sortorder, 'right ');
1636 $totalarray['nbfield']++;
1637}
1638if (!empty($arrayfields['p.multicurrency_total_tva']['checked'])) {
1639 print_liste_field_titre($arrayfields['p.multicurrency_total_tva']['label'], $_SERVER['PHP_SELF'], 'p.multicurrency_total_tva', '', $param, '', $sortfield, $sortorder, 'right ');
1640 $totalarray['nbfield']++;
1641}
1642if (!empty($arrayfields['p.multicurrency_total_ttc']['checked'])) {
1643 print_liste_field_titre($arrayfields['p.multicurrency_total_ttc']['label'], $_SERVER['PHP_SELF'], 'p.multicurrency_total_ttc', '', $param, '', $sortfield, $sortorder, 'right ');
1644 $totalarray['nbfield']++;
1645}
1646if (!empty($arrayfields['p.multicurrency_total_ht_invoiced']['checked'])) {
1647 print_liste_field_titre($arrayfields['p.multicurrency_total_ht_invoiced']['label'], $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right ');
1648 $totalarray['nbfield']++;
1649}
1650if (!empty($arrayfields['p.multicurrency_total_invoiced']['checked'])) {
1651 print_liste_field_titre($arrayfields['p.multicurrency_total_invoiced']['label'], $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right ');
1652 $totalarray['nbfield']++;
1653}
1654if (!empty($arrayfields['u.login']['checked'])) {
1655 print_liste_field_titre($arrayfields['u.login']['label'], $_SERVER["PHP_SELF"], 'u.login', '', $param, '', $sortfield, $sortorder);
1656 $totalarray['nbfield']++;
1657}
1658if (!empty($arrayfields['sale_representative']['checked'])) {
1659 print_liste_field_titre($arrayfields['sale_representative']['label'], $_SERVER["PHP_SELF"], "", "", "$param", '', $sortfield, $sortorder);
1660 $totalarray['nbfield']++;
1661}
1662if (!empty($arrayfields['total_pa']['checked'])) {
1663 print_liste_field_titre($arrayfields['total_pa']['label'], $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, 'right ');
1664 $totalarray['nbfield']++;
1665}
1666if (!empty($arrayfields['total_margin']['checked'])) {
1667 print_liste_field_titre($arrayfields['total_margin']['label'], $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, 'right ');
1668 $totalarray['nbfield']++;
1669}
1670if (!empty($arrayfields['total_margin_rate']['checked'])) {
1671 print_liste_field_titre($arrayfields['total_margin_rate']['label'], $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, 'right ');
1672 $totalarray['nbfield']++;
1673}
1674if (!empty($arrayfields['total_mark_rate']['checked'])) {
1675 print_liste_field_titre($arrayfields['total_mark_rate']['label'], $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, 'right ');
1676 $totalarray['nbfield']++;
1677}
1678// Extra fields
1679include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
1680// Hook fields
1681$parameters = array(
1682 'arrayfields' => $arrayfields,
1683 'param' => $param,
1684 'sortfield' => $sortfield,
1685 'sortorder' => $sortorder,
1686 'totalarray' => &$totalarray,
1687);
1688
1689$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1690
1691print $hookmanager->resPrint;
1692if (!empty($arrayfields['p.datec']['checked'])) {
1693 print_liste_field_titre($arrayfields['p.datec']['label'], $_SERVER["PHP_SELF"], "p.datec", "", $param, '', $sortfield, $sortorder, 'center nowraponall ');
1694 $totalarray['nbfield']++;
1695}
1696if (!empty($arrayfields['p.tms']['checked'])) {
1697 print_liste_field_titre($arrayfields['p.tms']['label'], $_SERVER["PHP_SELF"], "p.tms", "", $param, '', $sortfield, $sortorder, 'center nowraponall ');
1698 $totalarray['nbfield']++;
1699}
1700if (!empty($arrayfields['p.date_cloture']['checked'])) {
1701 print_liste_field_titre($arrayfields['p.date_cloture']['label'], $_SERVER["PHP_SELF"], "p.date_cloture", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder);
1702 $totalarray['nbfield']++;
1703}
1704if (!empty($arrayfields['p.note_public']['checked'])) {
1705 print_liste_field_titre($arrayfields['p.note_public']['label'], $_SERVER["PHP_SELF"], "p.note_public", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
1706 $totalarray['nbfield']++;
1707}
1708if (!empty($arrayfields['p.note_private']['checked'])) {
1709 print_liste_field_titre($arrayfields['p.note_private']['label'], $_SERVER["PHP_SELF"], "p.note_private", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
1710 $totalarray['nbfield']++;
1711}
1712if (!empty($arrayfields['p.fk_statut']['checked'])) {
1713 print_liste_field_titre($arrayfields['p.fk_statut']['label'], $_SERVER["PHP_SELF"], "p.fk_statut", "", $param, '', $sortfield, $sortorder, 'center ');
1714 $totalarray['nbfield']++;
1715}
1716if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1717 print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ');
1718 $totalarray['nbfield']++;
1719}
1720print '</tr>'."\n";
1721
1722// Loop on record
1723// --------------------------------------------------------------------
1724$typenArray = null;
1725$now = dol_now();
1726
1727$with_margin_info = false;
1728if (isModEnabled('margin') && (
1729 !empty($arrayfields['total_pa']['checked'])
1730 || !empty($arrayfields['total_margin']['checked'])
1731 || !empty($arrayfields['total_margin_rate']['checked'])
1732 || !empty($arrayfields['total_mark_rate']['checked'])
1733)
1734) {
1735 $with_margin_info = true;
1736}
1737
1738$total_ht = 0;
1739$total_margin = 0;
1740
1741$i = 0;
1742$savnbfield = $totalarray['nbfield'];
1743$totalarray = array();
1744$totalarray['nbfield'] = 0;
1745$imaxinloop = ($limit ? min($num, $limit) : $num);
1746while ($i < $imaxinloop) {
1747 $obj = $db->fetch_object($resql);
1748 if (empty($obj)) {
1749 break; // Should not happen
1750 }
1751 if ($search_option) {
1752 $param .= "&search_option=".urlencode($search_option);
1753 }
1754
1755 $objectstatic->id = $obj->rowid;
1756 $objectstatic->ref = $obj->ref;
1757 $objectstatic->ref_customer = $obj->ref_client;
1758 $objectstatic->note_public = $obj->note_public;
1759 $objectstatic->note_private = $obj->note_private;
1760 $objectstatic->statut = $obj->status;
1761 $objectstatic->status = $obj->status;
1762
1763 $companystatic->id = $obj->socid;
1764 $companystatic->name = $obj->name;
1765 $companystatic->name_alias = $obj->alias;
1766 $companystatic->client = $obj->client;
1767 $companystatic->fournisseur = $obj->fournisseur;
1768 $companystatic->code_client = $obj->code_client;
1769 $companystatic->email = $obj->email;
1770 $companystatic->phone = $obj->phone;
1771 $companystatic->address = $obj->address;
1772 $companystatic->zip = $obj->zip;
1773 $companystatic->town = $obj->town;
1774 $companystatic->country_code = $obj->country_code;
1775
1776 $projectstatic->id = $obj->project_id;
1777 $projectstatic->ref = $obj->project_ref;
1778 $projectstatic->title = $obj->project_label;
1779
1780 $totalInvoicedHT = 0;
1781 $totalInvoicedTTC = 0;
1782 $multicurrency_totalInvoicedHT = 0;
1783 $multicurrency_totalInvoicedTTC = 0;
1784
1785 $TInvoiceData = $objectstatic->InvoiceArrayList($obj->rowid);
1786
1787 if (!empty($TInvoiceData)) {
1788 foreach ($TInvoiceData as $invoiceData) {
1789 $invoice = new Facture($db);
1790 $invoice->fetch($invoiceData->facid);
1791
1792 if (getDolGlobalString('FACTURE_DEPOSITS_ARE_JUST_PAYMENTS') && $invoice->type == Facture::TYPE_DEPOSIT) {
1793 continue;
1794 }
1795
1796 $totalInvoicedHT += $invoice->total_ht;
1797 $totalInvoicedTTC += $invoice->total_ttc;
1798 $multicurrency_totalInvoicedHT += $invoice->multicurrency_total_ht;
1799 $multicurrency_totalInvoicedTTC += $invoice->multicurrency_total_ttc;
1800 }
1801 }
1802
1803 $marginInfo = array();
1804 if ($with_margin_info) {
1805 $objectstatic->fetch_lines();
1806 $marginInfo = $formmargin->getMarginInfosArray($objectstatic);
1807 $total_ht += $obj->total_ht;
1808 $total_margin += $marginInfo['total_margin'];
1809 }
1810
1811 if ($mode == 'kanban') {
1812 if ($i == 0) {
1813 print '<tr class="trkanban"><td colspan="'.$savnbfield.'">';
1814 print '<div class="box-flex-container kanban">';
1815 }
1816 // Output Kanban
1817 $objectstatic->thirdparty = $companystatic;
1818 $userstatic->fetch($obj->fk_user_author);
1819 $arrayofparams = array('selected' => in_array($object->id, $arrayofselected), 'authorlink' => $userstatic->getNomUrl(-2), 'projectlink' => $projectstatic->getNomUrl(2));
1820 print $objectstatic->getKanbanView('', $arrayofparams);
1821 if ($i == ($imaxinloop - 1)) {
1822 print '</div>';
1823 print '</td></tr>';
1824 }
1825 } else {
1826 print '<tr class="oddeven '.((getDolGlobalInt('MAIN_FINISHED_LINES_OPACITY') == 1 && $obj->status > 1) ? 'opacitymedium' : '').'">';
1827
1828 // Action column
1829 if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1830 print '<td class="nowrap" align="center">';
1831 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
1832 $selected = 0;
1833 if (in_array($obj->rowid, $arrayofselected)) {
1834 $selected = 1;
1835 }
1836 print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
1837 }
1838 print '</td>';
1839 if (!$i) {
1840 $totalarray['nbfield']++;
1841 }
1842 }
1843
1844 if (!empty($arrayfields['p.ref']['checked'])) {
1845 print '<td class="nowraponall">';
1846
1847 print '<table class="nobordernopadding"><tr class="nocellnopadd">';
1848 // Picto + Ref
1849 print '<td class="nobordernopadding nowraponall">';
1850 print $objectstatic->getNomUrl(1, '', '', 0, 1, (isset($conf->global->PROPAL_LIST_SHOW_NOTES) ? $conf->global->PROPAL_LIST_SHOW_NOTES : 1));
1851 print '</td>';
1852 // Warning
1853 $warnornote = '';
1854 if ($obj->status == Propal::STATUS_VALIDATED && $db->jdate($obj->dfv) < ($now - $conf->propal->cloture->warning_delay)) {
1855 $warnornote .= img_warning($langs->trans("Late"));
1856 }
1857 if ($warnornote) {
1858 print '<td style="min-width: 20px" class="nobordernopadding nowrap">';
1859 print $warnornote;
1860 print '</td>';
1861 }
1862 // Other picto tool
1863 print '<td width="16" class="nobordernopadding right">';
1864 $filename = dol_sanitizeFileName($obj->ref);
1865 $filedir = $conf->propal->multidir_output[$obj->propal_entity].'/'.dol_sanitizeFileName($obj->ref);
1866 $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->rowid;
1867 print $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir);
1868 print '</td></tr></table>';
1869
1870 print "</td>\n";
1871 if (!$i) {
1872 $totalarray['nbfield']++;
1873 }
1874 }
1875
1876 if (!empty($arrayfields['p.ref_client']['checked'])) {
1877 // Customer ref
1878 print '<td class="nowrap tdoverflowmax200">';
1879 print dol_escape_htmltag($obj->ref_client);
1880 print '</td>';
1881 if (!$i) {
1882 $totalarray['nbfield']++;
1883 }
1884 }
1885
1886 if (!empty($arrayfields['pr.ref']['checked'])) {
1887 // Project ref
1888 print '<td class="nowraponall">';
1889 if ($obj->project_id > 0) {
1890 print $projectstatic->getNomUrl(1);
1891 }
1892 print '</td>';
1893 if (!$i) {
1894 $totalarray['nbfield']++;
1895 }
1896 }
1897
1898 if (!empty($arrayfields['pr.title']['checked'])) {
1899 // Project label
1900 print '<td class="nowrap">';
1901 if ($obj->project_id > 0) {
1902 print dol_escape_htmltag($projectstatic->title);
1903 }
1904 print '</td>';
1905 if (!$i) {
1906 $totalarray['nbfield']++;
1907 }
1908 }
1909
1910 // Thirdparty
1911 if (!empty($arrayfields['s.nom']['checked'])) {
1912 print '<td class="tdoverflowmax150">';
1913 print $companystatic->getNomUrl(1, 'customer', 0, 0, 1, empty($arrayfields['s.name_alias']['checked']) ? 0 : 1);
1914 print '</td>';
1915 if (!$i) {
1916 $totalarray['nbfield']++;
1917 }
1918 }
1919
1920 // Alias
1921 if (!empty($arrayfields['s.name_alias']['checked'])) {
1922 print '<td class="tdoverflowmax200">';
1923 print $obj->alias;
1924 print '</td>';
1925 if (!$i) {
1926 $totalarray['nbfield']++;
1927 }
1928 }
1929
1930 // Town
1931 if (!empty($arrayfields['s.town']['checked'])) {
1932 print '<td class="tdoverflowmax100" title="'.dol_escape_htmltag($obj->town).'">';
1933 print dol_escape_htmltag($obj->town);
1934 print '</td>';
1935 if (!$i) {
1936 $totalarray['nbfield']++;
1937 }
1938 }
1939 // Zip
1940 if (!empty($arrayfields['s.zip']['checked'])) {
1941 print '<td class="nocellnopadd">';
1942 print $obj->zip;
1943 print '</td>';
1944 if (!$i) {
1945 $totalarray['nbfield']++;
1946 }
1947 }
1948 // State
1949 if (!empty($arrayfields['state.nom']['checked'])) {
1950 print "<td>".$obj->state_name."</td>\n";
1951 if (!$i) {
1952 $totalarray['nbfield']++;
1953 }
1954 }
1955 // Country
1956 if (!empty($arrayfields['country.code_iso']['checked'])) {
1957 print '<td class="center">';
1958 $tmparray = getCountry($obj->fk_pays, 'all');
1959 print $tmparray['label'];
1960 print '</td>';
1961 if (!$i) {
1962 $totalarray['nbfield']++;
1963 }
1964 }
1965 // Type ent
1966 if (!empty($arrayfields['typent.code']['checked'])) {
1967 if (!is_array($typenArray) || empty($typenArray)) {
1968 $typenArray = $formcompany->typent_array(1);
1969 }
1970
1971 print '<td class="center">';
1972 if (!empty($obj->typent_code)) {
1973 print $typenArray[$obj->typent_code];
1974 }
1975 print '</td>';
1976 if (!$i) {
1977 $totalarray['nbfield']++;
1978 }
1979 }
1980
1981 // Date proposal
1982 if (!empty($arrayfields['p.date']['checked'])) {
1983 print '<td class="center">';
1984 print dol_print_date($db->jdate($obj->dp), 'day');
1985 print "</td>\n";
1986 if (!$i) {
1987 $totalarray['nbfield']++;
1988 }
1989 }
1990
1991 // Date end validity
1992 if (!empty($arrayfields['p.fin_validite']['checked'])) {
1993 if ($obj->dfv) {
1994 print '<td class="center">'.dol_print_date($db->jdate($obj->dfv), 'day');
1995 print '</td>';
1996 } else {
1997 print '<td>&nbsp;</td>';
1998 }
1999 if (!$i) {
2000 $totalarray['nbfield']++;
2001 }
2002 }
2003 // Date delivery
2004 if (!empty($arrayfields['p.date_livraison']['checked'])) {
2005 if ($obj->ddelivery) {
2006 print '<td class="center">'.dol_print_date($db->jdate($obj->ddelivery), 'day');
2007 print '</td>';
2008 } else {
2009 print '<td>&nbsp;</td>';
2010 }
2011 if (!$i) {
2012 $totalarray['nbfield']++;
2013 }
2014 }
2015 // Date Signature
2016 if (!empty($arrayfields['p.date_signature']['checked'])) {
2017 if ($obj->dsignature) {
2018 print '<td class="center">'.dol_print_date($db->jdate($obj->dsignature), 'day');
2019 print '</td>';
2020 } else {
2021 print '<td>&nbsp;</td>';
2022 }
2023 if (!$i) {
2024 $totalarray['nbfield']++;
2025 }
2026 }
2027 // Availability
2028 if (!empty($arrayfields['ava.rowid']['checked'])) {
2029 print '<td class="center">';
2030 $form->form_availability(0, $obj->availability, 'none', 1);
2031 print '</td>';
2032 if (!$i) {
2033 $totalarray['nbfield']++;
2034 }
2035 }
2036 // Shipping Method
2037 if (!empty($arrayfields['p.fk_shipping_method']['checked'])) {
2038 print '<td>';
2039 $form->formSelectShippingMethod('', $obj->fk_shipping_method, 'none', 1);
2040 print '</td>';
2041 if (!$i) {
2042 $totalarray['nbfield']++;
2043 }
2044 }
2045 // Source - input reason
2046 if (!empty($arrayfields['p.fk_input_reason']['checked'])) {
2047 $labelInputReason = '';
2048 if ($obj->fk_input_reason > 0) {
2049 $labelInputReason = $form->cache_demand_reason[$obj->fk_input_reason]['label'];
2050 }
2051 print '<td class="tdoverflowmax125" title="'.dol_escape_htmltag($labelInputReason).'">';
2052 print dol_escape_htmltag($labelInputReason);
2053 print '</td>';
2054 if (!$i) {
2055 $totalarray['nbfield']++;
2056 }
2057 }
2058 // Payment terms
2059 if (!empty($arrayfields['p.fk_cond_reglement']['checked'])) {
2060 print '<td>';
2061 $form->form_conditions_reglement($_SERVER['PHP_SELF'], $obj->fk_cond_reglement, 'none', 0, '', 1, $obj->deposit_percent);
2062 print '</td>';
2063 if (!$i) {
2064 $totalarray['nbfield']++;
2065 }
2066 }
2067 // Payment mode
2068 if (!empty($arrayfields['p.fk_mode_reglement']['checked'])) {
2069 print '<td>';
2070 $form->form_modes_reglement($_SERVER['PHP_SELF'], $obj->fk_mode_reglement, 'none', '', -1);
2071 print '</td>';
2072 if (!$i) {
2073 $totalarray['nbfield']++;
2074 }
2075 }
2076 // Amount HT
2077 if (!empty($arrayfields['p.total_ht']['checked'])) {
2078 print '<td class="nowrap right"><span class="amount">'.price($obj->total_ht)."</span></td>\n";
2079 if (!$i) {
2080 $totalarray['nbfield']++;
2081 }
2082 if (!$i) {
2083 $totalarray['pos'][$totalarray['nbfield']] = 'p.total_ht';
2084 }
2085 if (empty($totalarray['val']['p.total_ht'])) {
2086 $totalarray['val']['p.total_ht'] = $obj->total_ht;
2087 } else {
2088 $totalarray['val']['p.total_ht'] += $obj->total_ht;
2089 }
2090 }
2091 // Amount VAT
2092 if (!empty($arrayfields['p.total_tva']['checked'])) {
2093 print '<td class="nowrap right"><span class="amount">'.price($obj->total_tva)."</span></td>\n";
2094 if (!$i) {
2095 $totalarray['nbfield']++;
2096 }
2097 if (!$i) {
2098 $totalarray['pos'][$totalarray['nbfield']] = 'p.total_tva';
2099 }
2100 if (empty($totalarray['val']['p.total_tva'])) {
2101 $totalarray['val']['p.total_tva'] = $obj->total_tva;
2102 } else {
2103 $totalarray['val']['p.total_tva'] += $obj->total_tva;
2104 }
2105 }
2106 // Amount TTC
2107 if (!empty($arrayfields['p.total_ttc']['checked'])) {
2108 print '<td class="nowrap right"><span class="amount">'.price($obj->total_ttc)."</span></td>\n";
2109 if (!$i) {
2110 $totalarray['nbfield']++;
2111 }
2112 if (!$i) {
2113 $totalarray['pos'][$totalarray['nbfield']] = 'p.total_ttc';
2114 }
2115 if (empty($totalarray['val']['p.total_ttc'])) {
2116 $totalarray['val']['p.total_ttc'] = $obj->total_ttc;
2117 } else {
2118 $totalarray['val']['p.total_ttc'] += $obj->total_ttc;
2119 }
2120 }
2121 // Amount invoiced HT
2122 if (!empty($arrayfields['p.total_ht_invoiced']['checked'])) {
2123 print '<td class="nowrap right"><span class="amount">'.price($totalInvoicedHT)."</span></td>\n";
2124 if (!$i) {
2125 $totalarray['nbfield']++;
2126 }
2127 if (!$i) {
2128 $totalarray['pos'][$totalarray['nbfield']] = 'p.total_ht_invoiced';
2129 }
2130 if (empty($totalarray['val']['p.total_ht_invoiced'])) {
2131 $totalarray['val']['p.total_ht_invoiced'] = $totalInvoicedHT;
2132 } else {
2133 $totalarray['val']['p.total_ht_invoiced'] += $totalInvoicedHT;
2134 }
2135 }
2136 // Amount invoiced TTC
2137 if (!empty($arrayfields['p.total_invoiced']['checked'])) {
2138 print '<td class="nowrap right"><span class="amount">'.price($totalInvoicedTTC)."</span></td>\n";
2139 if (!$i) {
2140 $totalarray['nbfield']++;
2141 }
2142 if (!$i) {
2143 $totalarray['pos'][$totalarray['nbfield']] = 'p.total_invoiced';
2144 }
2145 if (empty($totalarray['val']['p.total_invoiced'])) {
2146 $totalarray['val']['p.total_invoiced'] = $totalInvoicedTTC;
2147 } else {
2148 $totalarray['val']['p.total_invoiced'] += $totalInvoicedTTC;
2149 }
2150 }
2151 // Currency
2152 if (!empty($arrayfields['p.multicurrency_code']['checked'])) {
2153 print '<td class="nowrap">'.$obj->multicurrency_code.' - '.$langs->trans('Currency'.$obj->multicurrency_code)."</td>\n";
2154 if (!$i) {
2155 $totalarray['nbfield']++;
2156 }
2157 }
2158
2159 // Currency rate
2160 if (!empty($arrayfields['p.multicurrency_tx']['checked'])) {
2161 print '<td class="nowrap">';
2162 $form->form_multicurrency_rate($_SERVER['PHP_SELF'].'?id='.$obj->rowid, $obj->multicurrency_tx, 'none', $obj->multicurrency_code);
2163 print "</td>\n";
2164 if (!$i) {
2165 $totalarray['nbfield']++;
2166 }
2167 }
2168 // Amount HT
2169 if (!empty($arrayfields['p.multicurrency_total_ht']['checked'])) {
2170 print '<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_ht)."</span></td>\n";
2171 if (!$i) {
2172 $totalarray['nbfield']++;
2173 }
2174 }
2175 // Amount VAT
2176 if (!empty($arrayfields['p.multicurrency_total_tva']['checked'])) {
2177 print '<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_tva)."</span></td>\n";
2178 if (!$i) {
2179 $totalarray['nbfield']++;
2180 }
2181 }
2182 // Amount TTC
2183 if (!empty($arrayfields['p.multicurrency_total_ttc']['checked'])) {
2184 print '<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_ttc)."</span></td>\n";
2185 if (!$i) {
2186 $totalarray['nbfield']++;
2187 }
2188 }
2189 // Amount invoiced
2190 if (!empty($arrayfields['p.multicurrency_total_ht_invoiced']['checked'])) {
2191 print '<td class="nowrap right"><span class="amount">'.price($multicurrency_totalInvoicedHT)."</span></td>\n";
2192 if (!$i) {
2193 $totalarray['nbfield']++;
2194 }
2195 }
2196 // Amount invoiced
2197 if (!empty($arrayfields['p.multicurrency_total_invoiced']['checked'])) {
2198 print '<td class="nowrap right"><span class="amount">'.price($multicurrency_totalInvoicedTTC)."</span></td>\n";
2199 if (!$i) {
2200 $totalarray['nbfield']++;
2201 }
2202 }
2203
2204 $userstatic->id = $obj->fk_user_author;
2205 $userstatic->login = $obj->login;
2206 $userstatic->lastname = $obj->lastname;
2207 $userstatic->firstname = $obj->firstname;
2208 $userstatic->email = $obj->user_email;
2209 $userstatic->status = $obj->user_statut;
2210 $userstatic->entity = $obj->user_entity;
2211 $userstatic->photo = $obj->photo;
2212 $userstatic->office_phone = $obj->office_phone;
2213 $userstatic->office_fax = $obj->office_fax;
2214 $userstatic->user_mobile = $obj->user_mobile;
2215 $userstatic->job = $obj->job;
2216 $userstatic->gender = $obj->gender;
2217
2218 // Author
2219 if (!empty($arrayfields['u.login']['checked'])) {
2220 print '<td class="tdoverflowmax150">';
2221 if ($userstatic->id) {
2222 print $userstatic->getNomUrl(-1);
2223 }
2224 print "</td>\n";
2225 if (!$i) {
2226 $totalarray['nbfield']++;
2227 }
2228 }
2229
2230 if (!empty($arrayfields['sale_representative']['checked'])) {
2231 // Sales representatives
2232 print '<td class="tdoverflowmax125">';
2233 if ($obj->socid > 0) {
2234 $listsalesrepresentatives = $companystatic->getSalesRepresentatives($user);
2235 if ($listsalesrepresentatives < 0) {
2236 dol_print_error($db);
2237 }
2238 $nbofsalesrepresentative = count($listsalesrepresentatives);
2239 if ($nbofsalesrepresentative > 6) {
2240 // We print only number
2241 print $nbofsalesrepresentative;
2242 } elseif ($nbofsalesrepresentative > 0) {
2243 $userstatic = new User($db);
2244 $j = 0;
2245 foreach ($listsalesrepresentatives as $val) {
2246 $userstatic->id = $val['id'];
2247 $userstatic->lastname = $val['lastname'];
2248 $userstatic->firstname = $val['firstname'];
2249 $userstatic->email = $val['email'];
2250 $userstatic->status = $val['statut'];
2251 $userstatic->entity = $val['entity'];
2252 $userstatic->photo = $val['photo'];
2253 $userstatic->login = $val['login'];
2254 $userstatic->office_phone = $val['office_phone'];
2255 $userstatic->office_fax = $val['office_fax'];
2256 $userstatic->user_mobile = $val['user_mobile'];
2257 $userstatic->job = $val['job'];
2258 $userstatic->gender = $val['gender'];
2259 //print '<div class="float">':
2260 print ($nbofsalesrepresentative < 2) ? $userstatic->getNomUrl(-1, '', 0, 0, 12) : $userstatic->getNomUrl(-2);
2261 $j++;
2262 if ($j < $nbofsalesrepresentative) {
2263 print ' ';
2264 }
2265 //print '</div>';
2266 }
2267 }
2268 //else print $langs->trans("NoSalesRepresentativeAffected");
2269 } else {
2270 print '&nbsp;';
2271 }
2272 print '</td>';
2273 if (!$i) {
2274 $totalarray['nbfield']++;
2275 }
2276 }
2277
2278 // Total buying or cost price
2279 if (!empty($arrayfields['total_pa']['checked'])) {
2280 print '<td class="right nowrap">'.price($marginInfo['pa_total']).'</td>';
2281 if (!$i) {
2282 $totalarray['nbfield']++;
2283 }
2284 }
2285 // Total margin
2286 if (!empty($arrayfields['total_margin']['checked'])) {
2287 print '<td class="right nowrap">'.price($marginInfo['total_margin']).'</td>';
2288 if (!$i) {
2289 $totalarray['nbfield']++;
2290 }
2291 if (!$i) {
2292 $totalarray['pos'][$totalarray['nbfield']] = 'total_margin';
2293 }
2294 $totalarray['val']['total_margin'] = $total_margin;
2295 }
2296 // Total margin rate
2297 if (!empty($arrayfields['total_margin_rate']['checked'])) {
2298 print '<td class="right nowrap">'.(($marginInfo['total_margin_rate'] == '') ? '' : price($marginInfo['total_margin_rate'], 0, '', 0, 0, 2).'%').'</td>';
2299 if (!$i) {
2300 $totalarray['nbfield']++;
2301 }
2302 }
2303 // Total mark rate
2304 if (!empty($arrayfields['total_mark_rate']['checked'])) {
2305 print '<td class="right nowrap">'.(($marginInfo['total_mark_rate'] == '') ? '' : price($marginInfo['total_mark_rate'], 0, '', 0, 0, 2).'%').'</td>';
2306 if (!$i) {
2307 $totalarray['nbfield']++;
2308 }
2309 if (!$i) {
2310 $totalarray['pos'][$totalarray['nbfield']] = 'total_mark_rate';
2311 }
2312 if ($i >= $imaxinloop - 1) {
2313 if (!empty($total_ht)) {
2314 $totalarray['val']['total_mark_rate'] = price2num($total_margin * 100 / $total_ht, 'MT');
2315 } else {
2316 $totalarray['val']['total_mark_rate'] = '';
2317 }
2318 }
2319 }
2320
2321 // Extra fields
2322 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
2323 // Fields from hook
2324 $parameters = array('arrayfields' => $arrayfields, 'obj' => $obj, 'i' => $i, 'totalarray' => &$totalarray);
2325 $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
2326 print $hookmanager->resPrint;
2327 // Date creation
2328 if (!empty($arrayfields['p.datec']['checked'])) {
2329 print '<td align="center" class="nowrap">';
2330 print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser');
2331 print '</td>';
2332 if (!$i) {
2333 $totalarray['nbfield']++;
2334 }
2335 }
2336 // Date modification
2337 if (!empty($arrayfields['p.tms']['checked'])) {
2338 print '<td align="center" class="nowrap">';
2339 print dol_print_date($db->jdate($obj->date_modification), 'dayhour', 'tzuser');
2340 print '</td>';
2341 if (!$i) {
2342 $totalarray['nbfield']++;
2343 }
2344 }
2345 // Date cloture
2346 if (!empty($arrayfields['p.date_cloture']['checked'])) {
2347 print '<td align="center" class="nowrap">';
2348 print dol_print_date($db->jdate($obj->date_cloture), 'dayhour', 'tzuser');
2349 print '</td>';
2350 if (!$i) {
2351 $totalarray['nbfield']++;
2352 }
2353 }
2354 // Note public
2355 if (!empty($arrayfields['p.note_public']['checked'])) {
2356 print '<td class="sensiblehtmlcontent center">';
2357 print dolPrintHTML($obj->note_public);
2358 print '</td>';
2359 if (!$i) {
2360 $totalarray['nbfield']++;
2361 }
2362 }
2363 // Note private
2364 if (!empty($arrayfields['p.note_private']['checked'])) {
2365 print '<td class="sensiblehtmlcontent center">';
2366 print dolPrintHTML($obj->note_private);
2367 print '</td>';
2368 if (!$i) {
2369 $totalarray['nbfield']++;
2370 }
2371 }
2372 // Status
2373 if (!empty($arrayfields['p.fk_statut']['checked'])) {
2374 print '<td class="nowrap center">'.$objectstatic->getLibStatut(5).'</td>';
2375 if (!$i) {
2376 $totalarray['nbfield']++;
2377 }
2378 }
2379 // Action column
2380 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
2381 print '<td class="nowrap" align="center">';
2382 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
2383 $selected = 0;
2384 if (in_array($obj->rowid, $arrayofselected)) {
2385 $selected = 1;
2386 }
2387 print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
2388 }
2389 print '</td>';
2390 if (!$i) {
2391 $totalarray['nbfield']++;
2392 }
2393 }
2394
2395
2396 print '</tr>'."\n";
2397 }
2398
2399 $i++;
2400}
2401
2402// Show total line
2403include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
2404
2405// If no record found
2406if ($num == 0) {
2407 $colspan = 1;
2408 foreach ($arrayfields as $key => $val) {
2409 if (!empty($val['checked'])) {
2410 $colspan++;
2411 }
2412 }
2413 print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
2414}
2415
2416$db->free($resql);
2417
2418$parameters = array('arrayfields' => $arrayfields, 'sql' => $sql);
2419$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
2420print $hookmanager->resPrint;
2421
2422print '</table>'."\n";
2423print '</div>'."\n";
2424
2425print '</form>'."\n";
2426
2427if (in_array('builddoc', array_keys($arrayofmassactions)) && ($nbtotalofrecords === '' || $nbtotalofrecords)) {
2428 $hidegeneratedfilelistifempty = 1;
2429 if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) {
2430 $hidegeneratedfilelistifempty = 0;
2431 }
2432
2433 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
2434 $formfile = new FormFile($db);
2435
2436 // Show list of available documents
2437 $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
2438 $urlsource .= str_replace('&amp;', '&', $param);
2439
2440 $filedir = $diroutputmassaction;
2441 $genallowed = $permissiontoread;
2442 $delallowed = $permissiontoadd;
2443
2444 print $formfile->showdocuments('massfilesarea_proposals', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
2445}
2446
2447// End of page
2448llxFooter();
2449$db->close();
$id
Definition account.php:39
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:58
ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete='resolve', $idforemptyvalue='-1', $morecss='')
Convert a html select field into an ajax combobox.
Definition ajax.lib.php:457
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:70
Class to manage standard extra fields.
Class to manage invoices.
const TYPE_DEPOSIT
Deposit invoice.
Class to manage forms for categories.
Class to build HTML component for third parties management Only common components are here.
Class to offer components to list and upload files.
Class to manage generation of HTML components Only common components must be here.
Class permettant la generation de composants html autre Only common components are here.
Class permettant la generation de composants html autre Only common components are here.
Class with static methods for building HTML components related to products Only components common to ...
Class to manage generation of HTML components for proposal management.
Class to manage projects.
Class to manage proposals.
const STATUS_VALIDATED
Validated status.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage Dolibarr users.
getCountry($searchkey, $withcode='', $dbtouse=null, $outputlangs=null, $entconv=1, $searchlabel='')
Return country label, code or id from an id, code or label.
llxFooter()
Footer empty.
Definition document.php:107
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $selectlimitsuffix=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dolPrintHTML($s, $allowiframe=0)
Return a string (that can be on several lines) ready to be output on a HTML page.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
natural_search($fields, $value, $mode=0, $nofirstand=0)
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
setEventMessage($mesgs, $style='mesgs', $noduplicate=0, $attop=0)
Set event message in dol_events session object.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
dolGetButtonTitleSeparator($moreClass="")
Add space between dolGetButtonTitle.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.