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