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