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