dolibarr  13.0.2
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-2011 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-2018 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 Alexandre Spangaro <aspangaro@open-dsi.fr>
17  *
18  * This program is free software; you can redistribute it and/or modify
19  * it under the terms of the GNU General Public License as published by
20  * the Free Software Foundation; either version 3 of the License, or
21  * (at your option) any later version.
22  *
23  * This program is distributed in the hope that it will be useful,
24  * but WITHOUT ANY WARRANTY; without even the implied warranty of
25  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26  * GNU General Public License for more details.
27  *
28  * You should have received a copy of the GNU General Public License
29  * along with this program. If not, see <https://www.gnu.org/licenses/>.
30  */
31 
38 require '../../main.inc.php';
39 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
40 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
41 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formpropal.class.php';
42 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
43 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
44 require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
45 require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
46 require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
47 
48 // Load translation files required by the page
49 $langs->loadLangs(array('companies', 'propal', 'compta', 'bills', 'orders', 'products', 'deliveries', 'categories'));
50 
51 $socid = GETPOST('socid', 'int');
52 
53 $action = GETPOST('action', 'aZ09');
54 $massaction = GETPOST('massaction', 'alpha');
55 $show_files = GETPOST('show_files', 'int');
56 $confirm = GETPOST('confirm', 'alpha');
57 $toselect = GETPOST('toselect', 'array');
58 $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'proposallist';
59 
60 $search_user = GETPOST('search_user', 'int');
61 $search_sale = GETPOST('search_sale', 'int');
62 $search_ref = GETPOST('sf_ref') ?GETPOST('sf_ref', 'alpha') : GETPOST('search_ref', 'alpha');
63 $search_refcustomer = GETPOST('search_refcustomer', 'alpha');
64 
65 $search_refproject = GETPOST('search_refproject', 'alpha');
66 $search_project = GETPOST('search_project', 'alpha');
67 
68 $search_societe = GETPOST('search_societe', 'alpha');
69 $search_montant_ht = GETPOST('search_montant_ht', 'alpha');
70 $search_montant_vat = GETPOST('search_montant_vat', 'alpha');
71 $search_montant_ttc = GETPOST('search_montant_ttc', 'alpha');
72 $search_multicurrency_code = GETPOST('search_multicurrency_code', 'alpha');
73 $search_multicurrency_tx = GETPOST('search_multicurrency_tx', 'alpha');
74 $search_multicurrency_montant_ht = GETPOST('search_multicurrency_montant_ht', 'alpha');
75 $search_multicurrency_montant_vat = GETPOST('search_multicurrency_montant_vat', 'alpha');
76 $search_multicurrency_montant_ttc = GETPOST('search_multicurrency_montant_ttc', 'alpha');
77 $search_login = GETPOST('search_login', 'alpha');
78 $search_product_category = GETPOST('search_product_category', 'int');
79 $search_town = GETPOST('search_town', 'alpha');
80 $search_zip = GETPOST('search_zip', 'alpha');
81 $search_state = GETPOST("search_state");
82 $search_country = GETPOST("search_country", 'int');
83 $search_type_thirdparty = GETPOST("search_type_thirdparty", 'int');
84 $search_date_start = dol_mktime(0, 0, 0, GETPOST('search_date_startmonth', 'int'), GETPOST('search_date_startday', 'int'), GETPOST('search_date_startyear', 'int'));
85 $search_date_end = dol_mktime(23, 59, 59, GETPOST('search_date_endmonth', 'int'), GETPOST('search_date_endday', 'int'), GETPOST('search_date_endyear', 'int'));
86 $search_dateend_start = dol_mktime(0, 0, 0, GETPOST('search_dateend_startmonth', 'int'), GETPOST('search_dateend_startday', 'int'), GETPOST('search_dateend_startyear', 'int'));
87 $search_dateend_end = dol_mktime(23, 59, 59, GETPOST('search_dateend_endmonth', 'int'), GETPOST('search_dateend_endday', 'int'), GETPOST('search_dateend_endyear', 'int'));
88 $search_datedelivery_start = dol_mktime(0, 0, 0, GETPOST('search_datedelivery_startmonth', 'int'), GETPOST('search_datedelivery_startday', 'int'), GETPOST('search_datedelivery_startyear', 'int'));
89 $search_datedelivery_end = dol_mktime(23, 59, 59, GETPOST('search_datedelivery_endmonth', 'int'), GETPOST('search_datedelivery_endday', 'int'), GETPOST('search_datedelivery_endyear', 'int'));
90 $search_availability = GETPOST('search_availability', 'int');
91 $search_categ_cus = GETPOST("search_categ_cus", 'int');
92 $search_btn = GETPOST('button_search', 'alpha');
93 $search_remove_btn = GETPOST('button_removefilter', 'alpha');
94 
95 $search_status = GETPOST('search_status', 'alpha');
96 $optioncss = GETPOST('optioncss', 'alpha');
97 $object_statut = GETPOST('search_statut', 'alpha');
98 
99 $sall = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml'));
100 $mesg = (GETPOST("msg") ? GETPOST("msg") : GETPOST("mesg"));
101 
102 
103 $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
104 $sortfield = GETPOST("sortfield", 'alpha');
105 $sortorder = GETPOST("sortorder", 'alpha');
106 $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
107 if (empty($page) || $page == -1 || !empty($search_btn) || !empty($search_remove_btn) || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1
108 $offset = $limit * $page;
109 $pageprev = $page - 1;
110 $pagenext = $page + 1;
111 if (!$sortfield) $sortfield = 'p.ref';
112 if (!$sortorder) $sortorder = 'DESC';
113 
114 $permissiontoread = $user->rights->propal->lire;
115 $permissiontoadd = $user->rights->propal->write;
116 $permissiontodelete = $user->rights->propal->supprimer;
117 $permissiontoclose = $user->rights->propal->cloturer;
118 
119 // Security check
120 $module = 'propal';
121 $dbtable = '';
122 $objectid = '';
123 if (!empty($user->socid)) $socid = $user->socid;
124 if (!empty($socid))
125 {
126  $objectid = $socid;
127  $module = 'societe';
128  $dbtable = '&societe';
129 }
130 $result = restrictedArea($user, $module, $objectid, $dbtable);
131 
132 $diroutputmassaction = $conf->propal->multidir_output[$conf->entity].'/temp/massgeneration/'.$user->id;
133 
134 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
135 $object = new Propal($db);
136 $hookmanager->initHooks(array('propallist'));
137 $extrafields = new ExtraFields($db);
138 
139 // fetch optionals attributes and labels
140 $extrafields->fetch_name_optionals_label($object->table_element);
141 
142 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
143 
144 // List of fields to search into when doing a "search in all"
145 $fieldstosearchall = array(
146  'p.ref'=>'Ref',
147  'p.ref_client'=>'CustomerRef',
148  'pd.description'=>'Description',
149  's.nom'=>"ThirdParty",
150  's.name_alias'=>"AliasNameShort",
151  's.zip'=>"Zip",
152  's.town'=>"Town",
153  'p.note_public'=>'NotePublic',
154 );
155 if (empty($user->socid)) $fieldstosearchall["p.note_private"] = "NotePrivate";
156 
157 
158 $checkedtypetiers = 0;
159 $arrayfields = array(
160  'p.ref'=>array('label'=>"Ref", 'checked'=>1),
161  'p.ref_client'=>array('label'=>"RefCustomer", 'checked'=>1),
162  'pr.ref'=>array('label'=>"ProjectRef", 'checked'=>1, 'enabled'=>(empty($conf->projet->enabled) ? 0 : 1)),
163  'pr.title'=>array('label'=>"ProjectLabel", 'checked'=>0, 'enabled'=>(empty($conf->projet->enabled) ? 0 : 1)),
164  's.nom'=>array('label'=>"ThirdParty", 'checked'=>1),
165  's.town'=>array('label'=>"Town", 'checked'=>1),
166  's.zip'=>array('label'=>"Zip", 'checked'=>1),
167  'state.nom'=>array('label'=>"StateShort", 'checked'=>0),
168  'country.code_iso'=>array('label'=>"Country", 'checked'=>0),
169  'typent.code'=>array('label'=>"ThirdPartyType", 'checked'=>$checkedtypetiers),
170  'p.date'=>array('label'=>"Date", 'checked'=>1),
171  'p.fin_validite'=>array('label'=>"DateEnd", 'checked'=>1),
172  'p.date_livraison'=>array('label'=>"DeliveryDate", 'checked'=>0),
173  'ava.rowid'=>array('label'=>"AvailabilityPeriod", 'checked'=>0),
174  'p.total_ht'=>array('label'=>"AmountHT", 'checked'=>1),
175  'p.total_vat'=>array('label'=>"AmountVAT", 'checked'=>0),
176  'p.total_ttc'=>array('label'=>"AmountTTC", 'checked'=>0),
177  'p.total_ht_invoiced'=>array('label'=>"AmountInvoicedHT", 'checked'=>0, 'enabled'=>!empty($conf->global->PROPOSAL_SHOW_INVOICED_AMOUNT)),
178  'p.total_invoiced'=>array('label'=>"AmountInvoicedTTC", 'checked'=>0, 'enabled'=>!empty($conf->global->PROPOSAL_SHOW_INVOICED_AMOUNT)),
179  'p.multicurrency_code'=>array('label'=>'Currency', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)),
180  'p.multicurrency_tx'=>array('label'=>'CurrencyRate', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)),
181  'p.multicurrency_total_ht'=>array('label'=>'MulticurrencyAmountHT', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)),
182  'p.multicurrency_total_vat'=>array('label'=>'MulticurrencyAmountVAT', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)),
183  'p.multicurrency_total_ttc'=>array('label'=>'MulticurrencyAmountTTC', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)),
184  'p.multicurrency_total_ht_invoiced'=>array('label'=>'MulticurrencyAmountInvoicedHT', 'checked'=>0, 'enabled'=>!empty($conf->multicurrency->enabled) && !empty($conf->global->PROPOSAL_SHOW_INVOICED_AMOUNT)),
185  'p.multicurrency_total_invoiced'=>array('label'=>'MulticurrencyAmountInvoicedTTC', 'checked'=>0, 'enabled'=>!empty($conf->multicurrency->enabled) && !empty($conf->global->PROPOSAL_SHOW_INVOICED_AMOUNT)),
186  'u.login'=>array('label'=>"Author", 'checked'=>1, 'position'=>10),
187  'sale_representative'=>array('label'=>"SaleRepresentativesOfThirdParty", 'checked'=>1),
188  'p.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>500),
189  'p.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>500),
190  'p.date_cloture'=>array('label'=>"DateClosing", 'checked'=>0, 'position'=>500),
191  'p.note_public'=>array('label'=>'NotePublic', 'checked'=>0, 'position'=>510, 'enabled'=>(empty($conf->global->MAIN_LIST_ALLOW_PUBLIC_NOTES))),
192  'p.note_private'=>array('label'=>'NotePrivate', 'checked'=>0, 'position'=>511, 'enabled'=>(empty($conf->global->MAIN_LIST_ALLOW_PRIVATE_NOTES))),
193  'p.fk_statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000),
194 );
195 // Extra fields
196 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
197 
198 
199 /*
200  * Actions
201  */
202 
203 if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; }
204 if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; }
205 
206 $parameters = array('socid'=>$socid);
207 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
208 if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
209 
210 include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
211 
212 // Do we click on purge search criteria ?
213 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
214 {
215  $search_categ = '';
216  $search_user = '';
217  $search_sale = '';
218  $search_ref = '';
219  $search_refcustomer = '';
220  $search_refproject = '';
221  $search_project = '';
222  $search_societe = '';
223  $search_montant_ht = '';
224  $search_montant_vat = '';
225  $search_montant_ttc = '';
226  $search_multicurrency_code = '';
227  $search_multicurrency_tx = '';
228  $search_multicurrency_montant_ht = '';
229  $search_multicurrency_montant_vat = '';
230  $search_multicurrency_montant_ttc = '';
231  $search_login = '';
232  $search_product_category = '';
233  $search_town = '';
234  $search_zip = "";
235  $search_state = "";
236  $search_type = '';
237  $search_country = '';
238  $search_type_thirdparty = '';
239  $search_date_start = '';
240  $search_date_end = '';
241  $search_dateend_start = '';
242  $search_dateend_end = '';
243  $search_datedelivery_start = '';
244  $search_datedelivery_end = '';
245  $search_availability = '';
246  $search_status = '';
247  $object_statut = '';
248  $toselect = '';
249  $search_array_options = array();
250  $search_categ_cus = 0;
251 }
252 if ($object_statut != '') $search_status = $object_statut;
253 
254 
255 if (empty($reshook))
256 {
257  $objectclass = 'Propal';
258  $objectlabel = 'Proposals';
259  $uploaddir = $conf->propal->multidir_output[$conf->entity];
260  include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
261 }
262 
263 // Mass action validate (after a confirmation question, it is $action that is used).
264 if ($action == 'validate') {
265  if (GETPOST('confirm') == 'yes') {
266  $tmpproposal = new Propal($db);
267 
268  $db->begin();
269  $error = 0;
270  foreach ($toselect as $checked) {
271  if ($tmpproposal->fetch($checked)) {
272  if ($tmpproposal->statut == $tmpproposal::STATUS_DRAFT) {
273  if ($tmpproposal->valid($user)) {
274  setEventMessage($tmpproposal->ref." ".$langs->trans('PassedInOpenStatus'), 'mesgs');
275  } else {
276  setEventMessage($langs->trans('CantBeValidated'), 'errors');
277  $error++;
278  }
279  } else {
280  setEventMessage($tmpproposal->ref." ".$langs->trans('IsNotADraft'), 'errors');
281  $error++;
282  }
283  } else {
284  dol_print_error($db);
285  $error++;
286  }
287  }
288  if ($error) {
289  $db->rollback();
290  } else {
291  $db->commit();
292  }
293  }
294 }
295 
296 // Mass action sign (after a confirmation question, it is $action that is used).
297 if ($action == "sign") {
298  if (GETPOST('confirm') == 'yes') {
299  $tmpproposal = new Propal($db);
300 
301  $db->begin();
302  $error = 0;
303  foreach ($toselect as $checked) {
304  if ($tmpproposal->fetch($checked)) {
305  if ($tmpproposal->statut == $tmpproposal::STATUS_VALIDATED) {
306  $tmpproposal->statut = $tmpproposal::STATUS_SIGNED;
307 
308  if ($tmpproposal->update($user)) {
309  setEventMessage($tmpproposal->ref." ".$langs->trans('Signed'), 'mesgs');
310  } else {
311  dol_print_error($db);
312  $error++;
313  }
314  } else {
315  setEventMessage($tmpproposal->ref." ".$langs->trans('CantBeSign'), 'errors');
316  $error++;
317  }
318  } else {
319  dol_print_error($db);
320  $error++;
321  }
322  }
323  if ($error) {
324  $db->rollback();
325  } else {
326  $db->commit();
327  }
328  }
329 }
330 
331 
332 
333 /*
334  * View
335  */
336 
337 $now = dol_now();
338 
339 $form = new Form($db);
340 $formother = new FormOther($db);
341 $formfile = new FormFile($db);
342 $formpropal = new FormPropal($db);
343 $companystatic = new Societe($db);
344 $projectstatic = new Project($db);
345 $formcompany = new FormCompany($db);
346 
347 $help_url = 'EN:Commercial_Proposals|FR:Proposition_commerciale|ES:Presupuestos';
348 //llxHeader('',$langs->trans('Proposal'),$help_url);
349 
350 $sql = 'SELECT';
351 if ($sall || $search_product_category > 0 || $search_user > 0) $sql = 'SELECT DISTINCT';
352 $sql .= ' s.rowid as socid, s.nom as name, s.email, s.town, s.zip, s.fk_pays, s.client, s.code_client, ';
353 $sql .= " typent.code as typent_code,";
354 $sql .= " ava.rowid as availability,";
355 $sql .= " state.code_departement as state_code, state.nom as state_name,";
356 $sql .= ' p.rowid, p.entity, p.note_private, p.total_ht, p.tva as total_vat, p.total as 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,';
357 $sql .= ' p.fk_multicurrency, p.multicurrency_code, p.multicurrency_tx, p.multicurrency_total_ht, p.multicurrency_total_tva as multicurrency_total_vat, p.multicurrency_total_ttc,';
358 $sql .= ' p.datec as date_creation, p.tms as date_update, p.date_cloture as date_cloture,';
359 $sql .= ' p.note_public, p.note_private,';
360 $sql .= " pr.rowid as project_id, pr.ref as project_ref, pr.title as project_label,";
361 $sql .= ' u.login';
362 if (!$user->rights->societe->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user";
363 if ($search_categ_cus) $sql .= ", cc.fk_categorie, cc.fk_soc";
364 // Add fields from extrafields
365 if (!empty($extrafields->attributes[$object->table_element]['label'])) {
366  foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : '');
367 }
368 // Add fields from hooks
369 $parameters = array();
370 $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook
371 $sql .= $hookmanager->resPrint;
372 $sql = preg_replace('/, $/', '', $sql);
373 $sql .= ' FROM '.MAIN_DB_PREFIX.'societe as s';
374 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays)";
375 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typent)";
376 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)";
377 if (!empty($search_categ_cus)) $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
378 $sql .= ', '.MAIN_DB_PREFIX.'propal as p';
379 if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (p.rowid = ef.fk_object)";
380 if ($sall || $search_product_category > 0) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'propaldet as pd ON p.rowid=pd.fk_propal';
381 if ($search_product_category > 0) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product=pd.fk_product';
382 $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'user as u ON p.fk_user_author = u.rowid';
383 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet as pr ON pr.rowid = p.fk_projet";
384 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_availability as ava on (ava.rowid = p.fk_availability)";
385 // We'll need this table joined to the select in order to filter by sale
386 if ($search_sale > 0 || (!$user->rights->societe->client->voir && !$socid)) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
387 if ($search_user > 0)
388 {
389  $sql .= ", ".MAIN_DB_PREFIX."element_contact as c";
390  $sql .= ", ".MAIN_DB_PREFIX."c_type_contact as tc";
391 }
392 $sql .= ' WHERE p.fk_soc = s.rowid';
393 $sql .= ' AND p.entity IN ('.getEntity('propal').')';
394 if (!$user->rights->societe->client->voir && !$socid) //restriction
395 {
396  $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
397 }
398 
399 if ($search_town) $sql .= natural_search('s.town', $search_town);
400 if ($search_zip) $sql .= natural_search("s.zip", $search_zip);
401 if ($search_state) $sql .= natural_search("state.nom", $search_state);
402 if ($search_country) $sql .= " AND s.fk_pays IN (".$db->sanitize($db->escape($search_country)).')';
403 if ($search_type_thirdparty) $sql .= " AND s.fk_typent IN (".$db->sanitize($db->escape($search_type_thirdparty)).')';
404 if ($search_ref) $sql .= natural_search('p.ref', $search_ref);
405 if ($search_refcustomer) $sql .= natural_search('p.ref_client', $search_refcustomer);
406 if ($search_refproject) $sql .= natural_search('pr.ref', $search_refproject);
407 if ($search_project) $sql .= natural_search('pr.title', $search_project);
408 if ($search_availability) $sql .= " AND p.fk_availability IN (".$db->sanitize($db->escape($search_availability)).')';
409 
410 if ($search_societe) $sql .= natural_search('s.nom', $search_societe);
411 if ($search_login) $sql .= natural_search("u.login", $search_login);
412 if ($search_montant_ht != '') $sql .= natural_search("p.total_ht", $search_montant_ht, 1);
413 if ($search_montant_vat != '') $sql .= natural_search("p.tva", $search_montant_vat, 1);
414 if ($search_montant_ttc != '') $sql .= natural_search("p.total", $search_montant_ttc, 1);
415 if ($search_multicurrency_code != '') $sql .= ' AND p.multicurrency_code = "'.$db->escape($search_multicurrency_code).'"';
416 if ($search_multicurrency_tx != '') $sql .= natural_search('p.multicurrency_tx', $search_multicurrency_tx, 1);
417 if ($search_multicurrency_montant_ht != '') $sql .= natural_search('p.multicurrency_total_ht', $search_multicurrency_montant_ht, 1);
418 if ($search_multicurrency_montant_vat != '') $sql .= natural_search('p.multicurrency_total_tva', $search_multicurrency_montant_vat, 1);
419 if ($search_multicurrency_montant_ttc != '') $sql .= natural_search('p.multicurrency_total_ttc', $search_multicurrency_montant_ttc, 1);
420 if ($sall) {
421  $sql .= natural_search(array_keys($fieldstosearchall), $sall);
422 }
423 if ($search_categ_cus > 0) $sql .= " AND cc.fk_categorie = ".$db->escape($search_categ_cus);
424 if ($search_categ_cus == -2) $sql .= " AND cc.fk_categorie IS NULL";
425 
426 if ($search_product_category > 0) $sql .= " AND cp.fk_categorie = ".$db->escape($search_product_category);
427 if ($socid > 0) $sql .= ' AND s.rowid = '.$socid;
428 if ($search_status != '' && $search_status != '-1')
429 {
430  $sql .= ' AND p.fk_statut IN ('.$db->sanitize($db->escape($search_status)).')';
431 }
432 if ($search_date_start) $sql .= " AND p.datep >= '".$db->idate($search_date_start)."'";
433 if ($search_date_end) $sql .= " AND p.datep <= '".$db->idate($search_date_end)."'";
434 if ($search_dateend_start) $sql .= " AND p.fin_validite >= '".$db->idate($search_dateend_start)."'";
435 if ($search_dateend_end) $sql .= " AND p.fin_validite <= '".$db->idate($search_dateend_end)."'";
436 if ($search_datedelivery_start) $sql .= " AND p.date_livraison >= '".$db->idate($search_datedelivery_start)."'";
437 if ($search_datedelivery_end) $sql .= " AND p.date_livraison <= '".$db->idate($search_datedelivery_end)."'";
438 if ($search_sale > 0) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$db->escape($search_sale);
439 if ($search_user > 0)
440 {
441  $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 = ".$db->escape($search_user);
442 }
443 // Add where from extra fields
444 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
445 
446 // Add where from hooks
447 $parameters = array();
448 $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook
449 $sql .= $hookmanager->resPrint;
450 
451 $sql .= $db->order($sortfield, $sortorder);
452 $sql .= ', p.ref DESC';
453 
454 // Count total nb of records
455 $nbtotalofrecords = '';
456 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
457 {
458  $result = $db->query($sql);
459  $nbtotalofrecords = $db->num_rows($result);
460 
461  if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0
462  {
463  $page = 0;
464  $offset = 0;
465  }
466 }
467 
468 $sql .= $db->plimit($limit + 1, $offset);
469 
470 $resql = $db->query($sql);
471 
472 if ($resql)
473 {
474  $objectstatic = new Propal($db);
475  $userstatic = new User($db);
476 
477  if ($socid > 0)
478  {
479  $soc = new Societe($db);
480  $soc->fetch($socid);
481  $title = $langs->trans('ListOfProposals').' - '.$soc->name;
482  if (empty($search_societe)) $search_societe = $soc->name;
483  } else {
484  $title = $langs->trans('ListOfProposals');
485  }
486 
487  $num = $db->num_rows($resql);
488 
489  $arrayofselected = is_array($toselect) ? $toselect : array();
490 
491  if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $sall)
492  {
493  $obj = $db->fetch_object($resql);
494 
495  $id = $obj->rowid;
496 
497  header("Location: ".DOL_URL_ROOT.'/comm/propal/card.php?id='.$id);
498  exit;
499  }
500 
501  llxHeader('', $langs->trans('Proposal'), $help_url);
502 
503  $param = '&search_status='.urlencode($search_status);
504  if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
505  if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
506  if ($sall) $param .= '&sall='.urlencode($sall);
507  if ($search_date_start) $param .= '&search_date_start='.urlencode($search_date_start);
508  if ($search_date_end) $param .= '&search_date_end='.urlencode($search_date_end);
509  if ($search_dateend_start) $param .= '&search_dateend_start='.urlencode($search_dateend_start);
510  if ($search_dateend_end) $param .= '&search_dateend_end='.urlencode($search_dateend_end);
511  if ($search_datedelivery_start) $param .= '&search_datedelivery_start='.urlencode($search_datedelivery_start);
512  if ($search_datedelivery_end) $param .= '&search_datedelivery_end='.urlencode($search_datedelivery_end);
513  if ($search_ref) $param .= '&search_ref='.urlencode($search_ref);
514  if ($search_refcustomer) $param .= '&search_refcustomer='.urlencode($search_refcustomer);
515  if ($search_refproject) $param .= '&search_refproject='.urlencode($search_refproject);
516  if ($search_societe) $param .= '&search_societe='.urlencode($search_societe);
517  if ($search_user > 0) $param .= '&search_user='.urlencode($search_user);
518  if ($search_sale > 0) $param .= '&search_sale='.urlencode($search_sale);
519  if ($search_montant_ht) $param .= '&search_montant_ht='.urlencode($search_montant_ht);
520  if ($search_multicurrency_code != '') $param .= '&search_multicurrency_code='.urlencode($search_multicurrency_code);
521  if ($search_multicurrency_tx != '') $param .= '&search_multicurrency_tx='.urlencode($search_multicurrency_tx);
522  if ($search_multicurrency_montant_ht != '') $param .= '&search_multicurrency_montant_ht='.urlencode($search_multicurrency_montant_ht);
523  if ($search_multicurrency_montant_vat != '') $param .= '&search_multicurrency_montant_vat='.urlencode($search_multicurrency_montant_vat);
524  if ($search_multicurrency_montant_ttc != '') $param .= '&search_multicurrency_montant_ttc='.urlencode($search_multicurrency_montant_ttc);
525  if ($search_login) $param .= '&search_login='.urlencode($search_login);
526  if ($search_town) $param .= '&search_town='.urlencode($search_town);
527  if ($search_zip) $param .= '&search_zip='.urlencode($search_zip);
528  if ($socid > 0) $param .= '&socid='.urlencode($socid);
529  if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss);
530  if ($search_categ_cus > 0) $param .= '&search_categ_cus='.urlencode($search_categ_cus);
531  if ($search_product_category != '') $param .= '&search_product_category='.$search_product_category;
532 
533  // Add $param from extra fields
534  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
535 
536  // List of mass actions available
537  $arrayofmassactions = array(
538  'generate_doc'=>$langs->trans("ReGeneratePDF"),
539  'builddoc'=>$langs->trans("PDFMerge"),
540  'presend'=>$langs->trans("SendByMail"),
541  'prevalidate'=>$langs->trans("Validate"),
542  'presign'=>$langs->trans("Sign"),
543  );
544  if ($user->rights->propal->supprimer) $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
545  if ($user->rights->propal->cloturer) $arrayofmassactions['closed'] = $langs->trans("Close");
546  if (in_array($massaction, array('presend', 'predelete', 'closed'))) $arrayofmassactions = array();
547  $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
548 
549  $url = DOL_URL_ROOT.'/comm/propal/card.php?action=create';
550  if (!empty($socid)) $url .= '&socid='.$socid;
551  $newcardbutton = dolGetButtonTitle($langs->trans('NewPropal'), '', 'fa fa-plus-circle', $url, '', $user->rights->propal->creer);
552 
553  // Fields title search
554  print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
555  if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
556  print '<input type="hidden" name="token" value="'.newToken().'">';
557  print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
558  print '<input type="hidden" name="action" value="list">';
559  print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
560  print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
561  print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
562 
563  print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'propal', 0, $newcardbutton, '', $limit, 0, 0, 1);
564 
565  $topicmail = "SendPropalRef";
566  $modelmail = "propal_send";
567  $objecttmp = new Propal($db);
568  $trackid = 'pro'.$object->id;
569  include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
570 
571  if ($massaction == 'prevalidate')
572  {
573  print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmMassValidation"), $langs->trans("ConfirmMassValidationQuestion"), "validate", null, '', 0, 200, 500, 1);
574  }
575 
576  if ($massaction == 'presign')
577  {
578  print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmMassSignature"), $langs->trans("ConfirmMassSignatureQuestion"), "sign", null, '', 0, 200, 500, 1);
579  }
580 
581  if ($sall)
582  {
583  foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val);
584  print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'</div>';
585  }
586 
587  $i = 0;
588 
589  $moreforfilter = '';
590 
591  // If the user can view prospects other than his'
592  if ($user->rights->societe->client->voir || $socid)
593  {
594  $langs->load("commercial");
595  $moreforfilter .= '<div class="divsearchfield">';
596  $moreforfilter .= $langs->trans('ThirdPartiesOfSaleRepresentative').': ';
597  $moreforfilter .= $formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, 1, 'maxwidth200');
598  $moreforfilter .= '</div>';
599  }
600  // If the user can view prospects other than his'
601  if ($user->rights->societe->client->voir || $socid)
602  {
603  $moreforfilter .= '<div class="divsearchfield">';
604  $moreforfilter .= $langs->trans('LinkedToSpecificUsers').': ';
605  $moreforfilter .= $form->select_dolusers($search_user, 'search_user', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth200');
606  $moreforfilter .= '</div>';
607  }
608  // If the user can view products
609  if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire && ($user->rights->produit->lire || $user->rights->service->lire))
610  {
611  include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
612  $moreforfilter .= '<div class="divsearchfield">';
613  $moreforfilter .= $langs->trans('IncludingProductWithTag').': ';
614  $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, null, 'parent', null, null, 1);
615  $moreforfilter .= $form->selectarray('search_product_category', $cate_arbo, $search_product_category, 1, 0, 0, '', 0, 0, 0, 0, 'maxwidth300', 1);
616  $moreforfilter .= '</div>';
617  }
618  if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire)
619  {
620  require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
621  $moreforfilter .= '<div class="divsearchfield">';
622  $moreforfilter .= $langs->trans('CustomersProspectsCategoriesShort').': ';
623  $moreforfilter .= $formother->select_categories('customer', $search_categ_cus, 'search_categ_cus', 1);
624  $moreforfilter .= '</div>';
625  }
626  $parameters = array();
627  $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook
628  if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint;
629  else $moreforfilter = $hookmanager->resPrint;
630 
631  if (!empty($moreforfilter))
632  {
633  print '<div class="liste_titre liste_titre_bydiv centpercent">';
634  print $moreforfilter;
635  print '</div>';
636  }
637 
638  $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
639  $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
640  $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
641 
642  print '<div class="div-table-responsive">';
643  print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
644 
645  print '<tr class="liste_titre_filter">';
646  if (!empty($arrayfields['p.ref']['checked']))
647  {
648  print '<td class="liste_titre">';
649  print '<input class="flat maxwidth50" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
650  print '</td>';
651  }
652  if (!empty($arrayfields['p.ref_client']['checked']))
653  {
654  print '<td class="liste_titre">';
655  print '<input class="flat maxwidth50" type="text" name="search_refcustomer" value="'.dol_escape_htmltag($search_refcustomer).'">';
656  print '</td>';
657  }
658  if (!empty($arrayfields['pr.ref']['checked']))
659  {
660  print '<td class="liste_titre">';
661  print '<input class="flat maxwidth50" type="text" name="search_refproject" value="'.dol_escape_htmltag($search_refproject).'">';
662  print '</td>';
663  }
664  if (!empty($arrayfields['pr.title']['checked']))
665  {
666  print '<td class="liste_titre">';
667  print '<input class="flat maxwidth50" type="text" name="search_project" value="'.dol_escape_htmltag($search_project).'">';
668  print '</td>';
669  }
670  if (!empty($arrayfields['s.nom']['checked']))
671  {
672  print '<td class="liste_titre" align="left">';
673  print '<input class="flat maxwidth100" type="text" name="search_societe" value="'.dol_escape_htmltag($search_societe).'">';
674  print '</td>';
675  }
676  if (!empty($arrayfields['s.town']['checked'])) print '<td class="liste_titre"><input class="flat maxwidth50" type="text" name="search_town" value="'.$search_town.'"></td>';
677  if (!empty($arrayfields['s.zip']['checked'])) print '<td class="liste_titre"><input class="flat maxwidth50" type="text" name="search_zip" value="'.$search_zip.'"></td>';
678  // State
679  if (!empty($arrayfields['state.nom']['checked']))
680  {
681  print '<td class="liste_titre">';
682  print '<input class="flat maxwidth50" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).'">';
683  print '</td>';
684  }
685  // Country
686  if (!empty($arrayfields['country.code_iso']['checked']))
687  {
688  print '<td class="liste_titre" align="center">';
689  print $form->select_country($search_country, 'search_country', '', 0, 'minwidth100imp maxwidth100');
690  print '</td>';
691  }
692  // Company type
693  if (!empty($arrayfields['typent.code']['checked']))
694  {
695  print '<td class="liste_titre maxwidth100onsmartphone" align="center">';
696  print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 0, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT));
697  print ajax_combobox('search_type_thirdparty');
698  print '</td>';
699  }
700  // Date
701  if (!empty($arrayfields['p.date']['checked']))
702  {
703  print '<td class="liste_titre center">';
704  print '<div class="nowrap">';
705  print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
706  print '</div>';
707  print '<div class="nowrap">';
708  print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
709  print '</div>';
710  print '</td>';
711  }
712  // Date end
713  if (!empty($arrayfields['p.fin_validite']['checked']))
714  {
715  print '<td class="liste_titre center">';
716  print '<div class="nowrap">';
717  print $form->selectDate($search_dateend_start ? $search_dateend_start : -1, 'search_dateend_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
718  print '</div>';
719  print '<div class="nowrap">';
720  print $form->selectDate($search_dateend_end ? $search_dateend_end : -1, 'search_dateend_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
721  print '</div>';
722  print '</td>';
723  }
724  // Date delivery
725  if (!empty($arrayfields['p.date_livraison']['checked']))
726  {
727  print '<td class="liste_titre center">';
728  print '<div class="nowrap">';
729  print $form->selectDate($search_datedelivery_start ? $search_datedelivery_start : -1, 'search_datedelivery_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
730  print '</div>';
731  print '<div class="nowrap">';
732  print $form->selectDate($search_datedelivery_end ? $search_datedelivery_end : -1, 'search_datedelivery_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
733  print '</div>';
734  print '</td>';
735  }
736  // Availability
737  if (!empty($arrayfields['ava.rowid']['checked']))
738  {
739  print '<td class="liste_titre maxwidth100onsmartphone center">';
740  $form->selectAvailabilityDelay($search_availability, 'search_availability', '', 1);
741  print ajax_combobox('search_availability');
742  print '</td>';
743  }
744  if (!empty($arrayfields['p.total_ht']['checked']))
745  {
746  // Amount
747  print '<td class="liste_titre right">';
748  print '<input class="flat" type="text" size="5" name="search_montant_ht" value="'.dol_escape_htmltag($search_montant_ht).'">';
749  print '</td>';
750  }
751  if (!empty($arrayfields['p.total_vat']['checked']))
752  {
753  // Amount
754  print '<td class="liste_titre right">';
755  print '<input class="flat" type="text" size="5" name="search_montant_vat" value="'.dol_escape_htmltag($search_montant_vat).'">';
756  print '</td>';
757  }
758  if (!empty($arrayfields['p.total_ttc']['checked']))
759  {
760  // Amount
761  print '<td class="liste_titre right">';
762  print '<input class="flat" type="text" size="5" name="search_montant_ttc" value="'.dol_escape_htmltag($search_montant_ttc).'">';
763  print '</td>';
764  }
765  if (!empty($arrayfields['p.total_ht_invoiced']['checked']))
766  {
767  // Amount invoiced
768  print '<td class="liste_titre right">';
769  print '</td>';
770  }
771  if (!empty($arrayfields['p.total_invoiced']['checked']))
772  {
773  // Amount invoiced
774  print '<td class="liste_titre right">';
775  print '</td>';
776  }
777  if (!empty($arrayfields['p.multicurrency_code']['checked']))
778  {
779  // Currency
780  print '<td class="liste_titre">';
781  print $form->selectMultiCurrency($search_multicurrency_code, 'search_multicurrency_code', 1);
782  print '</td>';
783  }
784  if (!empty($arrayfields['p.multicurrency_tx']['checked']))
785  {
786  // Currency rate
787  print '<td class="liste_titre">';
788  print '<input class="flat" type="text" size="4" name="search_multicurrency_tx" value="'.dol_escape_htmltag($search_multicurrency_tx).'">';
789  print '</td>';
790  }
791  if (!empty($arrayfields['p.multicurrency_total_ht']['checked']))
792  {
793  // Amount
794  print '<td class="liste_titre right">';
795  print '<input class="flat" type="text" size="4" name="search_multicurrency_montant_ht" value="'.dol_escape_htmltag($search_multicurrency_montant_ht).'">';
796  print '</td>';
797  }
798  if (!empty($arrayfields['p.multicurrency_total_vat']['checked']))
799  {
800  // Amount
801  print '<td class="liste_titre right">';
802  print '<input class="flat" type="text" size="4" name="search_multicurrency_montant_vat" value="'.dol_escape_htmltag($search_multicurrency_montant_vat).'">';
803  print '</td>';
804  }
805  if (!empty($arrayfields['p.multicurrency_total_ttc']['checked']))
806  {
807  // Amount
808  print '<td class="liste_titre right">';
809  print '<input class="flat" type="text" size="4" name="search_multicurrency_montant_ttc" value="'.dol_escape_htmltag($search_multicurrency_montant_ttc).'">';
810  print '</td>';
811  }
812  if (!empty($arrayfields['p.multicurrency_total_ht_invoiced']['checked']))
813  {
814  // Amount invoiced
815  print '<td class="liste_titre right">';
816  print '</td>';
817  }
818  if (!empty($arrayfields['p.multicurrency_total_invoiced']['checked']))
819  {
820  // Amount invoiced
821  print '<td class="liste_titre right">';
822  print '</td>';
823  }
824  if (!empty($arrayfields['u.login']['checked']))
825  {
826  // Author
827  print '<td class="liste_titre" align="center">';
828  print '<input class="flat" size="4" type="text" name="search_login" value="'.dol_escape_htmltag($search_login).'">';
829  print '</td>';
830  }
831  if (!empty($arrayfields['sale_representative']['checked']))
832  {
833  print '<td class="liste_titre"></td>';
834  }
835  // Extra fields
836  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
837 
838  // Fields from hook
839  $parameters = array('arrayfields'=>$arrayfields);
840  $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
841  print $hookmanager->resPrint;
842  // Date creation
843  if (!empty($arrayfields['p.datec']['checked']))
844  {
845  print '<td class="liste_titre">';
846  print '</td>';
847  }
848  // Date modification
849  if (!empty($arrayfields['p.tms']['checked']))
850  {
851  print '<td class="liste_titre">';
852  print '</td>';
853  }
854  // Date cloture
855  if (!empty($arrayfields['p.date_cloture']['checked']))
856  {
857  print '<td class="liste_titre">';
858  print '</td>';
859  }
860  if (!empty($arrayfields['p.note_public']['checked']))
861  {
862  // Note public
863  print '<td class="liste_titre">';
864  print '</td>';
865  }
866  if (!empty($arrayfields['p.note_private']['checked']))
867  {
868  // Note private
869  print '<td class="liste_titre">';
870  print '</td>';
871  }
872  // Status
873  if (!empty($arrayfields['p.fk_statut']['checked']))
874  {
875  print '<td class="liste_titre maxwidthonsmartphone right">';
876  $formpropal->selectProposalStatus($search_status, 1, 0, 1, 'customer', 'search_statut');
877  print '</td>';
878  }
879  // Action column
880  print '<td class="liste_titre" align="middle">';
881  $searchpicto = $form->showFilterButtons();
882  print $searchpicto;
883  print '</td>';
884 
885  print "</tr>\n";
886 
887 
888  // Fields title
889  print '<tr class="liste_titre">';
890  if (!empty($arrayfields['p.ref']['checked'])) print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], 'p.ref', '', $param, '', $sortfield, $sortorder);
891  if (!empty($arrayfields['p.ref_client']['checked'])) print_liste_field_titre($arrayfields['p.ref_client']['label'], $_SERVER["PHP_SELF"], 'p.ref_client', '', $param, '', $sortfield, $sortorder);
892  if (!empty($arrayfields['pr.ref']['checked'])) print_liste_field_titre($arrayfields['pr.ref']['label'], $_SERVER["PHP_SELF"], 'pr.ref', '', $param, '', $sortfield, $sortorder);
893  if (!empty($arrayfields['pr.title']['checked'])) print_liste_field_titre($arrayfields['pr.title']['label'], $_SERVER["PHP_SELF"], 'pr.title', '', $param, '', $sortfield, $sortorder);
894  if (!empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], 's.nom', '', $param, '', $sortfield, $sortorder);
895  if (!empty($arrayfields['s.town']['checked'])) print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], 's.town', '', $param, '', $sortfield, $sortorder);
896  if (!empty($arrayfields['s.zip']['checked'])) print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], 's.zip', '', $param, '', $sortfield, $sortorder);
897  if (!empty($arrayfields['state.nom']['checked'])) print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder);
898  if (!empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, 'align="center"', $sortfield, $sortorder);
899  if (!empty($arrayfields['typent.code']['checked'])) print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, 'align="center"', $sortfield, $sortorder);
900  if (!empty($arrayfields['p.date']['checked'])) print_liste_field_titre($arrayfields['p.date']['label'], $_SERVER["PHP_SELF"], 'p.datep', '', $param, 'align="center"', $sortfield, $sortorder);
901  if (!empty($arrayfields['p.fin_validite']['checked'])) print_liste_field_titre($arrayfields['p.fin_validite']['label'], $_SERVER["PHP_SELF"], 'dfv', '', $param, 'align="center"', $sortfield, $sortorder);
902  if (!empty($arrayfields['p.date_livraison']['checked'])) print_liste_field_titre($arrayfields['p.date_livraison']['label'], $_SERVER["PHP_SELF"], 'ddelivery', '', $param, 'align="center"', $sortfield, $sortorder);
903  if (!empty($arrayfields['ava.rowid']['checked'])) print_liste_field_titre($arrayfields['ava.rowid']['label'], $_SERVER["PHP_SELF"], 'availability', '', $param, '', $sortfield, $sortorder);
904  if (!empty($arrayfields['p.total_ht']['checked'])) print_liste_field_titre($arrayfields['p.total_ht']['label'], $_SERVER["PHP_SELF"], 'p.total_ht', '', $param, 'class="right"', $sortfield, $sortorder);
905  if (!empty($arrayfields['p.total_vat']['checked'])) print_liste_field_titre($arrayfields['p.total_vat']['label'], $_SERVER["PHP_SELF"], 'p.tva', '', $param, 'class="right"', $sortfield, $sortorder);
906  if (!empty($arrayfields['p.total_ttc']['checked'])) print_liste_field_titre($arrayfields['p.total_ttc']['label'], $_SERVER["PHP_SELF"], 'p.total', '', $param, 'class="right"', $sortfield, $sortorder);
907  if (!empty($arrayfields['p.total_ht_invoiced']['checked'])) print_liste_field_titre($arrayfields['p.total_ht_invoiced']['label'], $_SERVER["PHP_SELF"], '', '', $param, 'class="right"', $sortfield, $sortorder);
908  if (!empty($arrayfields['p.total_invoiced']['checked'])) print_liste_field_titre($arrayfields['p.total_invoiced']['label'], $_SERVER["PHP_SELF"], '', '', $param, 'class="right"', $sortfield, $sortorder);
909  if (!empty($arrayfields['p.multicurrency_code']['checked'])) print_liste_field_titre($arrayfields['p.multicurrency_code']['label'], $_SERVER['PHP_SELF'], 'p.multicurrency_code', '', $param, '', $sortfield, $sortorder);
910  if (!empty($arrayfields['p.multicurrency_tx']['checked'])) print_liste_field_titre($arrayfields['p.multicurrency_tx']['label'], $_SERVER['PHP_SELF'], 'p.multicurrency_tx', '', $param, '', $sortfield, $sortorder);
911  if (!empty($arrayfields['p.multicurrency_total_ht']['checked'])) print_liste_field_titre($arrayfields['p.multicurrency_total_ht']['label'], $_SERVER['PHP_SELF'], 'p.multicurrency_total_ht', '', $param, 'class="right"', $sortfield, $sortorder);
912  if (!empty($arrayfields['p.multicurrency_total_vat']['checked'])) print_liste_field_titre($arrayfields['p.multicurrency_total_vat']['label'], $_SERVER['PHP_SELF'], 'p.multicurrency_total_tva', '', $param, 'class="right"', $sortfield, $sortorder);
913  if (!empty($arrayfields['p.multicurrency_total_ttc']['checked'])) print_liste_field_titre($arrayfields['p.multicurrency_total_ttc']['label'], $_SERVER['PHP_SELF'], 'p.multicurrency_total_ttc', '', $param, 'class="right"', $sortfield, $sortorder);
914  if (!empty($arrayfields['p.multicurrency_total_ht_invoiced']['checked'])) print_liste_field_titre($arrayfields['p.multicurrency_total_ht_invoiced']['label'], $_SERVER["PHP_SELF"], '', '', $param, 'class="right"', $sortfield, $sortorder);
915  if (!empty($arrayfields['p.multicurrency_total_invoiced']['checked'])) print_liste_field_titre($arrayfields['p.multicurrency_total_invoiced']['label'], $_SERVER["PHP_SELF"], '', '', $param, 'class="right"', $sortfield, $sortorder);
916  if (!empty($arrayfields['u.login']['checked'])) print_liste_field_titre($arrayfields['u.login']['label'], $_SERVER["PHP_SELF"], 'u.login', '', $param, 'align="center"', $sortfield, $sortorder);
917  if (!empty($arrayfields['sale_representative']['checked'])) print_liste_field_titre($arrayfields['sale_representative']['label'], $_SERVER["PHP_SELF"], "", "", "$param", '', $sortfield, $sortorder);
918  // Extra fields
919  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
920  // Hook fields
921  $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
922  $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
923  print $hookmanager->resPrint;
924  if (!empty($arrayfields['p.datec']['checked'])) print_liste_field_titre($arrayfields['p.datec']['label'], $_SERVER["PHP_SELF"], "p.datec", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder);
925  if (!empty($arrayfields['p.tms']['checked'])) print_liste_field_titre($arrayfields['p.tms']['label'], $_SERVER["PHP_SELF"], "p.tms", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder);
926  if (!empty($arrayfields['p.date_cloture']['checked'])) print_liste_field_titre($arrayfields['p.date_cloture']['label'], $_SERVER["PHP_SELF"], "p.date_cloture", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder);
927  if (!empty($arrayfields['p.note_public']['checked'])) print_liste_field_titre($arrayfields['p.note_public']['label'], $_SERVER["PHP_SELF"], "p.note_public", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
928  if (!empty($arrayfields['p.note_private']['checked'])) print_liste_field_titre($arrayfields['p.note_private']['label'], $_SERVER["PHP_SELF"], "p.note_private", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
929  if (!empty($arrayfields['p.fk_statut']['checked'])) print_liste_field_titre($arrayfields['p.fk_statut']['label'], $_SERVER["PHP_SELF"], "p.fk_statut", "", $param, 'class="right"', $sortfield, $sortorder);
930  print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ');
931  print '</tr>'."\n";
932 
933  $now = dol_now();
934  $i = 0;
935  $totalarray = array();
936  $typenArray = null;
937 
938  while ($i < min($num, $limit))
939  {
940  $obj = $db->fetch_object($resql);
941 
942  $objectstatic->id = $obj->rowid;
943  $objectstatic->ref = $obj->ref;
944  $objectstatic->ref_client = $obj->ref_client;
945  $objectstatic->note_public = $obj->note_public;
946  $objectstatic->note_private = $obj->note_private;
947  $objectstatic->statut = $obj->status;
948  $objectstatic->status = $obj->status;
949 
950  $companystatic->id = $obj->socid;
951  $companystatic->name = $obj->name;
952  $companystatic->client = $obj->client;
953  $companystatic->code_client = $obj->code_client;
954  $companystatic->email = $obj->email;
955 
956  $projectstatic->id = $obj->project_id;
957  $projectstatic->ref = $obj->project_ref;
958  $projectstatic->title = $obj->project_label;
959 
960  $totalInvoicedHT = 0;
961  $totalInvoicedTTC = 0;
962  $multicurrency_totalInvoicedHT = 0;
963  $multicurrency_totalInvoicedTTC = 0;
964 
965  $TInvoiceData = $objectstatic->InvoiceArrayList($obj->rowid);
966 
967  if (!empty($TInvoiceData))
968  {
969  foreach ($TInvoiceData as $invoiceData)
970  {
971  $invoice = new Facture($db);
972  $invoice->fetch($invoiceData->facid);
973 
974  if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS) && $invoice->type == Facture::TYPE_DEPOSIT) continue;
975 
976  $totalInvoicedHT += $invoice->total_ht;
977  $totalInvoicedTTC += $invoice->total_ttc;
978  $multicurrency_totalInvoicedHT += $invoice->multicurrency_total_ht;
979  $multicurrency_totalInvoicedTTC += $invoice->multicurrency_total_ttc;
980  }
981  }
982 
983  print '<tr class="oddeven">';
984 
985  if (!empty($arrayfields['p.ref']['checked']))
986  {
987  print '<td class="nowraponall">';
988 
989  print '<table class="nobordernopadding"><tr class="nocellnopadd">';
990  // Picto + Ref
991  print '<td class="nobordernopadding nowraponall">';
992  print $objectstatic->getNomUrl(1, '', '', 0, 1, (isset($conf->global->PROPAL_LIST_SHOW_NOTES) ? $conf->global->PROPAL_LIST_SHOW_NOTES : 1));
993  print '</td>';
994  // Warning
995  $warnornote = '';
996  if ($obj->status == Propal::STATUS_VALIDATED && $db->jdate($obj->dfv) < ($now - $conf->propal->cloture->warning_delay)) $warnornote .= img_warning($langs->trans("Late"));
997  if ($warnornote)
998  {
999  print '<td style="min-width: 20px" class="nobordernopadding nowrap">';
1000  print $warnornote;
1001  print '</td>';
1002  }
1003  // Other picto tool
1004  print '<td width="16" class="nobordernopadding right">';
1005  $filename = dol_sanitizeFileName($obj->ref);
1006  $filedir = $conf->propal->multidir_output[$obj->entity].'/'.dol_sanitizeFileName($obj->ref);
1007  $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->rowid;
1008  print $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir);
1009  print '</td></tr></table>';
1010 
1011  print "</td>\n";
1012  if (!$i) $totalarray['nbfield']++;
1013  }
1014 
1015  if (!empty($arrayfields['p.ref_client']['checked']))
1016  {
1017  // Customer ref
1018  print '<td class="nowrap tdoverflowmax200">';
1019  print $obj->ref_client;
1020  print '</td>';
1021  if (!$i) $totalarray['nbfield']++;
1022  }
1023 
1024  if (!empty($arrayfields['pr.ref']['checked']))
1025  {
1026  // Project ref
1027  print '<td class="nowrap">';
1028  if ($obj->project_id > 0) {
1029  print $projectstatic->getNomUrl(1);
1030  }
1031  print '</td>';
1032  if (!$i) $totalarray['nbfield']++;
1033  }
1034 
1035  if (!empty($arrayfields['pr.title']['checked']))
1036  {
1037  // Project label
1038  print '<td class="nowrap">';
1039  if ($obj->project_id > 0) {
1040  print $projectstatic->title;
1041  }
1042  print '</td>';
1043  if (!$i) $totalarray['nbfield']++;
1044  }
1045 
1046  // Thirdparty
1047  if (!empty($arrayfields['s.nom']['checked']))
1048  {
1049  print '<td class="tdoverflowmax200">';
1050  print $companystatic->getNomUrl(1, 'customer');
1051  print '</td>';
1052  if (!$i) $totalarray['nbfield']++;
1053  }
1054 
1055  // Town
1056  if (!empty($arrayfields['s.town']['checked']))
1057  {
1058  print '<td class="nocellnopadd">';
1059  print $obj->town;
1060  print '</td>';
1061  if (!$i) $totalarray['nbfield']++;
1062  }
1063  // Zip
1064  if (!empty($arrayfields['s.zip']['checked']))
1065  {
1066  print '<td class="nocellnopadd">';
1067  print $obj->zip;
1068  print '</td>';
1069  if (!$i) $totalarray['nbfield']++;
1070  }
1071  // State
1072  if (!empty($arrayfields['state.nom']['checked']))
1073  {
1074  print "<td>".$obj->state_name."</td>\n";
1075  if (!$i) $totalarray['nbfield']++;
1076  }
1077  // Country
1078  if (!empty($arrayfields['country.code_iso']['checked']))
1079  {
1080  print '<td class="center">';
1081  $tmparray = getCountry($obj->fk_pays, 'all');
1082  print $tmparray['label'];
1083  print '</td>';
1084  if (!$i) $totalarray['nbfield']++;
1085  }
1086  // Type ent
1087  if (!empty($arrayfields['typent.code']['checked']))
1088  {
1089  if (!is_array($typenArray) || empty($typenArray)) $typenArray = $formcompany->typent_array(1);
1090 
1091  print '<td class="center">';
1092  print $typenArray[$obj->typent_code];
1093  print '</td>';
1094  if (!$i) $totalarray['nbfield']++;
1095  }
1096 
1097  // Date proposal
1098  if (!empty($arrayfields['p.date']['checked']))
1099  {
1100  print '<td class="center">';
1101  print dol_print_date($db->jdate($obj->dp), 'day');
1102  print "</td>\n";
1103  if (!$i) $totalarray['nbfield']++;
1104  }
1105 
1106  // Date end validity
1107  if (!empty($arrayfields['p.fin_validite']['checked']))
1108  {
1109  if ($obj->dfv)
1110  {
1111  print '<td class="center">'.dol_print_date($db->jdate($obj->dfv), 'day');
1112  print '</td>';
1113  } else {
1114  print '<td>&nbsp;</td>';
1115  }
1116  if (!$i) $totalarray['nbfield']++;
1117  }
1118  // Date delivery
1119  if (!empty($arrayfields['p.date_livraison']['checked']))
1120  {
1121  if ($obj->ddelivery)
1122  {
1123  print '<td class="center">'.dol_print_date($db->jdate($obj->ddelivery), 'day');
1124  print '</td>';
1125  } else {
1126  print '<td>&nbsp;</td>';
1127  }
1128  if (!$i) $totalarray['nbfield']++;
1129  }
1130  // Availability
1131  if (!empty($arrayfields['ava.rowid']['checked']))
1132  {
1133  print '<td class="center">';
1134  $form->form_availability('', $obj->availability, 'none', 1);
1135  print '</td>';
1136  if (!$i) $totalarray['nbfield']++;
1137  }
1138 
1139  // Amount HT
1140  if (!empty($arrayfields['p.total_ht']['checked']))
1141  {
1142  print '<td class="nowrap right">'.price($obj->total_ht)."</td>\n";
1143  if (!$i) $totalarray['nbfield']++;
1144  if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'p.total_ht';
1145  $totalarray['val']['p.total_ht'] += $obj->total_ht;
1146  }
1147  // Amount VAT
1148  if (!empty($arrayfields['p.total_vat']['checked']))
1149  {
1150  print '<td class="nowrap right">'.price($obj->total_vat)."</td>\n";
1151  if (!$i) $totalarray['nbfield']++;
1152  if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'p.total_vat';
1153  $totalarray['val']['p.total_vat'] += $obj->total_vat;
1154  }
1155  // Amount TTC
1156  if (!empty($arrayfields['p.total_ttc']['checked']))
1157  {
1158  print '<td class="nowrap right">'.price($obj->total_ttc)."</td>\n";
1159  if (!$i) $totalarray['nbfield']++;
1160  if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'p.total_ttc';
1161  $totalarray['val']['p.total_ttc'] += $obj->total_ttc;
1162  }
1163  // Amount invoiced
1164  if (!empty($arrayfields['p.total_ht_invoiced']['checked']))
1165  {
1166  print '<td class="nowrap right">'.price($totalInvoicedHT)."</td>\n";
1167  if (!$i) $totalarray['nbfield']++;
1168  if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'p.total_ht_invoiced';
1169  $totalarray['val']['p.total_ht_invoiced'] += $totalInvoicedHT;
1170  }
1171  // Amount invoiced
1172  if (!empty($arrayfields['p.total_invoiced']['checked']))
1173  {
1174  print '<td class="nowrap right">'.price($totalInvoicedTTC)."</td>\n";
1175  if (!$i) $totalarray['nbfield']++;
1176  if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'p.total_invoiced';
1177  $totalarray['val']['p.total_invoiced'] += $totalInvoicedTTC;
1178  }
1179 
1180  // Currency
1181  if (!empty($arrayfields['p.multicurrency_code']['checked']))
1182  {
1183  print '<td class="nowrap">'.$obj->multicurrency_code.' - '.$langs->trans('Currency'.$obj->multicurrency_code)."</td>\n";
1184  if (!$i) $totalarray['nbfield']++;
1185  }
1186 
1187  // Currency rate
1188  if (!empty($arrayfields['p.multicurrency_tx']['checked']))
1189  {
1190  print '<td class="nowrap">';
1191  $form->form_multicurrency_rate($_SERVER['PHP_SELF'].'?id='.$obj->rowid, $obj->multicurrency_tx, 'none', $obj->multicurrency_code);
1192  print "</td>\n";
1193  if (!$i) $totalarray['nbfield']++;
1194  }
1195  // Amount HT
1196  if (!empty($arrayfields['p.multicurrency_total_ht']['checked']))
1197  {
1198  print '<td class="right nowrap">'.price($obj->multicurrency_total_ht)."</td>\n";
1199  if (!$i) $totalarray['nbfield']++;
1200  }
1201  // Amount VAT
1202  if (!empty($arrayfields['p.multicurrency_total_vat']['checked']))
1203  {
1204  print '<td class="right nowrap">'.price($obj->multicurrency_total_vat)."</td>\n";
1205  if (!$i) $totalarray['nbfield']++;
1206  }
1207  // Amount TTC
1208  if (!empty($arrayfields['p.multicurrency_total_ttc']['checked']))
1209  {
1210  print '<td class="right nowrap">'.price($obj->multicurrency_total_ttc)."</td>\n";
1211  if (!$i) $totalarray['nbfield']++;
1212  }
1213  // Amount invoiced
1214  if (!empty($arrayfields['p.multicurrency_total_ht_invoiced']['checked']))
1215  {
1216  print '<td class="nowrap right">'.price($multicurrency_totalInvoicedHT)."</td>\n";
1217  if (!$i) $totalarray['nbfield']++;
1218  }
1219  // Amount invoiced
1220  if (!empty($arrayfields['p.multicurrency_total_invoiced']['checked']))
1221  {
1222  print '<td class="nowrap right">'.price($multicurrency_totalInvoicedTTC)."</td>\n";
1223  if (!$i) $totalarray['nbfield']++;
1224  }
1225 
1226  $userstatic->id = $obj->fk_user_author;
1227  $userstatic->login = $obj->login;
1228 
1229  // Author
1230  if (!empty($arrayfields['u.login']['checked']))
1231  {
1232  print '<td class="center nowraponall">';
1233  if ($userstatic->id) print $userstatic->getLoginUrl(1);
1234  print "</td>\n";
1235  if (!$i) $totalarray['nbfield']++;
1236  }
1237 
1238  if (!empty($arrayfields['sale_representative']['checked']))
1239  {
1240  // Sales representatives
1241  print '<td>';
1242  if ($obj->socid > 0)
1243  {
1244  $listsalesrepresentatives = $companystatic->getSalesRepresentatives($user);
1245  if ($listsalesrepresentatives < 0) dol_print_error($db);
1246  $nbofsalesrepresentative = count($listsalesrepresentatives);
1247  if ($nbofsalesrepresentative > 3) // We print only number
1248  {
1249  print $nbofsalesrepresentative;
1250  } elseif ($nbofsalesrepresentative > 0)
1251  {
1252  $userstatic = new User($db);
1253  $j = 0;
1254  foreach ($listsalesrepresentatives as $val)
1255  {
1256  $userstatic->id = $val['id'];
1257  $userstatic->lastname = $val['lastname'];
1258  $userstatic->firstname = $val['firstname'];
1259  $userstatic->email = $val['email'];
1260  $userstatic->statut = $val['statut'];
1261  $userstatic->entity = $val['entity'];
1262  $userstatic->photo = $val['photo'];
1263 
1264  //print '<div class="float">':
1265  print $userstatic->getNomUrl(-2);
1266  $j++;
1267  if ($j < $nbofsalesrepresentative) print ' ';
1268  //print '</div>';
1269  }
1270  }
1271  //else print $langs->trans("NoSalesRepresentativeAffected");
1272  } else {
1273  print '&nbsp';
1274  }
1275  print '</td>';
1276  if (!$i) $totalarray['nbfield']++;
1277  }
1278 
1279  // Extra fields
1280  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
1281  // Fields from hook
1282  $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
1283  $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook
1284  print $hookmanager->resPrint;
1285  // Date creation
1286  if (!empty($arrayfields['p.datec']['checked']))
1287  {
1288  print '<td align="center" class="nowrap">';
1289  print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser');
1290  print '</td>';
1291  if (!$i) $totalarray['nbfield']++;
1292  }
1293  // Date modification
1294  if (!empty($arrayfields['p.tms']['checked']))
1295  {
1296  print '<td align="center" class="nowrap">';
1297  print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser');
1298  print '</td>';
1299  if (!$i) $totalarray['nbfield']++;
1300  }
1301  // Date cloture
1302  if (!empty($arrayfields['p.date_cloture']['checked']))
1303  {
1304  print '<td align="center" class="nowrap">';
1305  print dol_print_date($db->jdate($obj->date_cloture), 'dayhour', 'tzuser');
1306  print '</td>';
1307  if (!$i) $totalarray['nbfield']++;
1308  }
1309  // Note public
1310  if (!empty($arrayfields['p.note_public']['checked']))
1311  {
1312  print '<td class="center">';
1313  print dol_escape_htmltag($obj->note_public);
1314  print '</td>';
1315  if (!$i) $totalarray['nbfield']++;
1316  }
1317  // Note private
1318  if (!empty($arrayfields['p.note_private']['checked']))
1319  {
1320  print '<td class="center">';
1321  print dol_escape_htmltag($obj->note_private);
1322  print '</td>';
1323  if (!$i) $totalarray['nbfield']++;
1324  }
1325  // Status
1326  if (!empty($arrayfields['p.fk_statut']['checked']))
1327  {
1328  print '<td class="nowrap right">'.$objectstatic->getLibStatut(5).'</td>';
1329  if (!$i) $totalarray['nbfield']++;
1330  }
1331  // Action column
1332  print '<td class="nowrap" align="center">';
1333  if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
1334  {
1335  $selected = 0;
1336  if (in_array($obj->rowid, $arrayofselected)) $selected = 1;
1337  print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
1338  }
1339  print '</td>';
1340  if (!$i) $totalarray['nbfield']++;
1341 
1342  print "</tr>\n";
1343 
1344  $i++;
1345  }
1346 
1347  // Show total line
1348  include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
1349 
1350  $db->free($resql);
1351 
1352  $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql);
1353  $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook
1354  print $hookmanager->resPrint;
1355 
1356  print '</table>'."\n";
1357  print '</div>'."\n";
1358 
1359  print '</form>'."\n";
1360 
1361  $hidegeneratedfilelistifempty = 1;
1362  if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0;
1363 
1364  // Show list of available documents
1365  $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
1366  $urlsource .= str_replace('&amp;', '&', $param);
1367 
1368  $filedir = $diroutputmassaction;
1369  $genallowed = $user->rights->propal->lire;
1370  $delallowed = $user->rights->propal->creer;
1371 
1372  print $formfile->showdocuments('massfilesarea_proposals', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
1373 } else {
1374  dol_print_error($db);
1375 }
1376 
1377 // End of page
1378 llxFooter();
1379 $db->close();
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
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...
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.
dol_now($mode= 'auto')
Return date for now.
Class to manage Dolibarr users.
Definition: user.class.php:44
setEventMessage($mesgs, $style= 'mesgs')
Set event message in dol_events session object.
ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete= 'resolve')
Convert a html select field into an ajax combobox.
Definition: ajax.lib.php:391
Class to manage generation of HTML components for proposal management.
img_warning($titlealt= 'default', $moreatt= '', $morecss= 'pictowarning')
Show warning logo.
llxHeader()
Empty header.
Definition: wrapper.php:45
Class to build HTML component for third parties management Only common components are here...
Class to manage standard extra fields.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages 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.
Class to manage generation of HTML components Only common components must be here.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname.
Class to manage third parties objects (customers, suppliers, prospects...)
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
Class to manage projects.
Classe permettant la generation de composants html autre Only common components are here...
restrictedArea($user, $features, $objectid=0, $tableandshare= '', $feature2= '', $dbt_keyfield= 'fk_soc', $dbt_select= 'rowid', $isdraft=0)
Check permissions of a user to show a page and an object.
natural_search($fields, $value, $mode=0, $nofirstand=0)
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
dol_sanitizeFileName($str, $newstr= '_', $unaccent=1)
Clean a string to use it as a file name.
Class to offer components to list and upload files.
print $_SERVER["PHP_SELF"]
Edit parameters.
const TYPE_DEPOSIT
Deposit invoice.
print
Draft customers invoices.
Definition: index.php:89
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
Definition: index.php:1232
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
const STATUS_VALIDATED
Validated status.
Class to manage invoices.
llxFooter()
Empty footer.
Definition: wrapper.php:59
if(!defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN'
Draft customers invoices.
getCountry($searchkey, $withcode= '', $dbtouse=0, $outputlangs= '', $entconv=1, $searchlabel= '')
Return country label, code or id from an id, code or label.
Class to manage proposals.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $keepmoretags= '', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields...