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