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