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