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