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