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