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