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