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