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