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