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