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