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