dolibarr  17.0.4
list.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2001-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2004-2017 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-2019 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) 2016 Ferran Marcet <fmarcet@2byte.es>
13  * Copyright (C) 2018 Charlene Benke <charlie@patas-monkey.com>
14  * Copyright (C) 2021 Alexandre Spangaro <aspangaro@open-dsi.fr>
15  *
16  * This program is free software; you can redistribute it and/or modify
17  * it under the terms of the GNU General Public License as published by
18  * the Free Software Foundation; either version 3 of the License, or
19  * (at your option) any later version.
20  *
21  * This program is distributed in the hope that it will be useful,
22  * but WITHOUT ANY WARRANTY; without even the implied warranty of
23  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24  * GNU General Public License for more details.
25  *
26  * You should have received a copy of the GNU General Public License
27  * along with this program. If not, see <https://www.gnu.org/licenses/>.
28  */
29 
36 // Load Dolibarr environment
37 require '../main.inc.php';
38 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
39 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
40 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
41 require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
42 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formpropal.class.php';
43 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
44 require_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class.php';
45 if (!empty($conf->project->enabled)) {
46  require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
47 }
48 
49 // Load translation files required by the page
50 $langs->loadLangs(array('companies', 'propal', 'supplier_proposal', 'compta', 'bills', 'orders', 'products'));
51 
52 $socid = GETPOST('socid', 'int');
53 
54 $action = GETPOST('action', 'aZ09');
55 $massaction = GETPOST('massaction', 'alpha');
56 $show_files = GETPOST('show_files', 'int');
57 $confirm = GETPOST('confirm', 'alpha');
58 $toselect = GETPOST('toselect', 'array');
59 $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'supplierproposallist';
60 
61 $search_user = GETPOST('search_user', 'int');
62 $search_sale = GETPOST('search_sale', 'int');
63 $search_ref = GETPOST('sf_ref') ?GETPOST('sf_ref', 'alpha') : GETPOST('search_ref', 'alpha');
64 $search_societe = GETPOST('search_societe', 'alpha');
65 $search_societe_alias = GETPOST('search_societe_alias', 'alpha');
66 $search_login = GETPOST('search_login', 'alpha');
67 $search_town = GETPOST('search_town', 'alpha');
68 $search_zip = GETPOST('search_zip', 'alpha');
69 $search_state = GETPOST("search_state");
70 $search_country = GETPOST("search_country", 'int');
71 $search_date_startday = GETPOST('search_date_startday', 'int');
72 $search_date_startmonth = GETPOST('search_date_startmonth', 'int');
73 $search_date_startyear = GETPOST('search_date_startyear', 'int');
74 $search_date_endday = GETPOST('search_date_endday', 'int');
75 $search_date_endmonth = GETPOST('search_date_endmonth', 'int');
76 $search_date_endyear = GETPOST('search_date_endyear', 'int');
77 $search_date_start = dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear); // Use tzserver
78 $search_date_end = dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear);
79 $search_date_valid_startday = GETPOST('search_date_valid_startday', 'int');
80 $search_date_valid_startmonth = GETPOST('search_date_valid_startmonth', 'int');
81 $search_date_valid_startyear = GETPOST('search_date_valid_startyear', 'int');
82 $search_date_valid_endday = GETPOST('search_date_valid_endday', 'int');
83 $search_date_valid_endmonth = GETPOST('search_date_valid_endmonth', 'int');
84 $search_date_valid_endyear = GETPOST('search_date_valid_endyear', 'int');
85 $search_date_valid_start = dol_mktime(0, 0, 0, $search_date_valid_startmonth, $search_date_valid_startday, $search_date_valid_startyear); // Use tzserver
86 $search_date_valid_end = dol_mktime(23, 59, 59, $search_date_valid_endmonth, $search_date_valid_endday, $search_date_valid_endyear);
87 $search_type_thirdparty = GETPOST("search_type_thirdparty", 'int');
88 $search_montant_ht = GETPOST('search_montant_ht', 'alpha');
89 $search_montant_vat = GETPOST('search_montant_vat', 'alpha');
90 $search_montant_ttc = GETPOST('search_montant_ttc', 'alpha');
91 $search_multicurrency_code = GETPOST('search_multicurrency_code', 'alpha');
92 $search_multicurrency_tx = GETPOST('search_multicurrency_tx', 'alpha');
93 $search_multicurrency_montant_ht = GETPOST('search_multicurrency_montant_ht', 'alpha');
94 $search_multicurrency_montant_vat = GETPOST('search_multicurrency_montant_vat', 'alpha');
95 $search_multicurrency_montant_ttc = GETPOST('search_multicurrency_montant_ttc', 'alpha');
96 $search_status = GETPOST('search_status', 'int');
97 $search_product_category = GETPOST('search_product_category', 'int');
98 
99 $object_statut = $db->escape(GETPOST('supplier_proposal_statut'));
100 $search_btn = GETPOST('button_search', 'alpha');
101 $search_remove_btn = GETPOST('button_removefilter', 'alpha');
102 
103 $sall = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml'));
104 
105 $mesg = (GETPOST("msg") ? GETPOST("msg") : GETPOST("mesg"));
106 
107 $optioncss = GETPOST('optioncss', 'alpha');
108 $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
109 $sortfield = GETPOST('sortfield', 'aZ09comma');
110 $sortorder = GETPOST('sortorder', 'aZ09comma');
111 $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
112 if (empty($page) || $page == -1 || !empty($search_btn) || !empty($search_remove_btn) || (empty($toselect) && $massaction === '0')) {
113  $page = 0;
114 } // If $page is not defined, or '' or -1
115 $offset = $limit * $page;
116 $pageprev = $page - 1;
117 $pagenext = $page + 1;
118 if (!$sortfield) {
119  $sortfield = 'sp.date_livraison';
120 }
121 if (!$sortorder) {
122  $sortorder = 'DESC';
123 }
124 
125 if ($object_statut != '') {
126  $search_status = $object_statut;
127 }
128 
129 // Nombre de ligne pour choix de produit/service predefinis
130 $NBLINES = 4;
131 
132 // Security check
133 $module = 'supplier_proposal';
134 $dbtable = '';
135 $objectid = '';
136 if (!empty($user->socid)) {
137  $socid = $user->socid;
138 }
139 if (!empty($socid)) {
140  $objectid = $socid;
141  $module = 'societe';
142  $dbtable = '&societe';
143 }
144 
145 $diroutputmassaction = $conf->supplier_proposal->dir_output.'/temp/massgeneration/'.$user->id;
146 
147 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
148 $object = new SupplierProposal($db);
149 $hookmanager->initHooks(array('supplier_proposallist'));
150 $extrafields = new ExtraFields($db);
151 
152 // fetch optionals attributes and labels
153 $extrafields->fetch_name_optionals_label($object->table_element);
154 
155 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
156 
157 
158 // List of fields to search into when doing a "search in all"
159 $fieldstosearchall = array(
160  'sp.ref'=>'Ref',
161  's.nom'=>'Supplier',
162  'pd.description'=>'Description',
163  'sp.note_public'=>'NotePublic',
164 );
165 if (empty($user->socid)) {
166  $fieldstosearchall["p.note_private"] = "NotePrivate";
167 }
168 
169 $checkedtypetiers = 0;
170 $arrayfields = array(
171  'sp.ref'=>array('label'=>$langs->trans("Ref"), 'checked'=>1),
172  's.nom'=>array('label'=>$langs->trans("Supplier"), 'checked'=>1),
173  's.name_alias'=>array('label'=>"AliasNameShort", 'checked'=>0),
174  's.town'=>array('label'=>$langs->trans("Town"), 'checked'=>1),
175  's.zip'=>array('label'=>$langs->trans("Zip"), 'checked'=>1),
176  'state.nom'=>array('label'=>$langs->trans("StateShort"), 'checked'=>0),
177  'country.code_iso'=>array('label'=>$langs->trans("Country"), 'checked'=>0),
178  'typent.code'=>array('label'=>$langs->trans("ThirdPartyType"), 'checked'=>$checkedtypetiers),
179  'sp.date_valid'=>array('label'=>$langs->trans("DateValidation"), 'checked'=>1),
180  'sp.date_livraison'=>array('label'=>$langs->trans("DateEnd"), 'checked'=>1),
181  'sp.total_ht'=>array('label'=>$langs->trans("AmountHT"), 'checked'=>1),
182  'sp.total_tva'=>array('label'=>$langs->trans("AmountVAT"), 'checked'=>0),
183  'sp.total_ttc'=>array('label'=>$langs->trans("AmountTTC"), 'checked'=>0),
184  'sp.multicurrency_code'=>array('label'=>'Currency', 'checked'=>0, 'enabled'=>(!isModEnabled("multicurrency") ? 0 : 1)),
185  'sp.multicurrency_tx'=>array('label'=>'CurrencyRate', 'checked'=>0, 'enabled'=>(!isModEnabled("multicurrency") ? 0 : 1)),
186  'sp.multicurrency_total_ht'=>array('label'=>'MulticurrencyAmountHT', 'checked'=>0, 'enabled'=>(!isModEnabled("multicurrency") ? 0 : 1)),
187  'sp.multicurrency_total_vat'=>array('label'=>'MulticurrencyAmountVAT', 'checked'=>0, 'enabled'=>(!isModEnabled("multicurrency") ? 0 : 1)),
188  'sp.multicurrency_total_ttc'=>array('label'=>'MulticurrencyAmountTTC', 'checked'=>0, 'enabled'=>(!isModEnabled("multicurrency") ? 0 : 1)),
189  'u.login'=>array('label'=>$langs->trans("Author"), 'checked'=>1, 'position'=>10),
190  'sp.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500),
191  'sp.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500),
192  'sp.fk_statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000),
193 );
194 // Extra fields
195 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
196 
197 $object->fields = dol_sort_array($object->fields, 'position');
198 $arrayfields = dol_sort_array($arrayfields, 'position');
199 
200 $result = restrictedArea($user, $module, $objectid, $dbtable);
201 
202 $permissiontoread = $user->rights->supplier_proposal->lire;
203 $permissiontodelete = $user->rights->supplier_proposal->supprimer;
204 
205 
206 /*
207  * Actions
208  */
209 
210 if (GETPOST('cancel', 'alpha')) {
211  $action = 'list';
212  $massaction = '';
213 }
214 if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
215  $massaction = '';
216 }
217 
218 $parameters = array('socid'=>$socid);
219 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
220 if ($reshook < 0) {
221  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
222 }
223 
224 if (empty($reshook)) {
225  // Selection of new fields
226  include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
227 
228  // Purge search criteria
229  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
230  $search_categ = '';
231  $search_user = '';
232  $search_sale = '';
233  $search_ref = '';
234  $search_societe = '';
235  $search_societe_alias = '';
236  $search_montant_ht = '';
237  $search_montant_vat = '';
238  $search_montant_ttc = '';
239  $search_multicurrency_code = '';
240  $search_multicurrency_tx = '';
241  $search_multicurrency_montant_ht = '';
242  $search_multicurrency_montant_vat = '';
243  $search_multicurrency_montant_ttc = '';
244  $search_login = '';
245  $search_product_category = '';
246  $search_town = '';
247  $search_zip = "";
248  $search_state = "";
249  $search_type = '';
250  $search_country = '';
251  $search_type_thirdparty = '';
252  $search_date_startday = '';
253  $search_date_startmonth = '';
254  $search_date_startyear = '';
255  $search_date_endday = '';
256  $search_date_endmonth = '';
257  $search_date_endyear = '';
258  $search_date_start = '';
259  $search_date_end = '';
260  $search_date_valid_startday = '';
261  $search_date_valid_startmonth = '';
262  $search_date_valid_startyear = '';
263  $search_date_valid_endday = '';
264  $search_date_valid_endmonth = '';
265  $search_date_valid_endyear = '';
266  $search_date_valid_start = '';
267  $search_date_valid_end = '';
268  $search_status = '';
269  $object_statut = '';
270  }
271 
272  $objectclass = 'SupplierProposal';
273  $objectlabel = 'SupplierProposals';
274  $uploaddir = $conf->supplier_proposal->dir_output;
275  include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
276 }
277 
278 
279 /*
280  * View
281  */
282 
283 $form = new Form($db);
284 $formother = new FormOther($db);
285 $formfile = new FormFile($db);
286 $formpropal = new FormPropal($db);
287 $companystatic = new Societe($db);
288 $formcompany = new FormCompany($db);
289 
290 $now = dol_now();
291 
292 $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
293 $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
294 
295 $title = $langs->trans('ListOfSupplierProposals');
296 $help_url = 'EN:Ask_Price_Supplier|FR:Demande_de_prix_fournisseur';
297 
298 
299 // Build and execute select
300 // --------------------------------------------------------------------
301 $sql = 'SELECT';
302 if ($sall || $search_user > 0) {
303  $sql = 'SELECT DISTINCT';
304 }
305 $sql .= ' s.rowid as socid, s.nom as name, s.name_alias as alias, s.town, s.zip, s.fk_pays, s.client, s.code_client,';
306 $sql .= " typent.code as typent_code,";
307 $sql .= " state.code_departement as state_code, state.nom as state_name,";
308 $sql .= ' sp.rowid, sp.note_public, sp.note_private, sp.total_ht, sp.total_tva, sp.total_ttc, sp.localtax1, sp.localtax2, sp.ref, sp.fk_statut as status, sp.fk_user_author, sp.date_valid, sp.date_livraison as dp,';
309 $sql .= ' sp.fk_multicurrency, sp.multicurrency_code, sp.multicurrency_tx, sp.multicurrency_total_ht, sp.multicurrency_total_tva as multicurrency_total_vat, sp.multicurrency_total_ttc,';
310 $sql .= ' sp.datec as date_creation, sp.tms as date_update,';
311 $sql .= " p.rowid as project_id, p.ref as project_ref,";
312 if (empty($user->rights->societe->client->voir) && !$socid) {
313  $sql .= " sc.fk_soc, sc.fk_user,";
314 }
315 $sql .= " u.firstname, u.lastname, u.photo, u.login, u.statut as ustatus, u.admin, u.employee, u.email as uemail";
316 // Add fields from extrafields
317 if (!empty($extrafields->attributes[$object->table_element]['label'])) {
318  foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
319  $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : '');
320  }
321 }
322 // Add fields from hooks
323 $parameters = array();
324 $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook
325 $sql .= $hookmanager->resPrint;
326 $sql .= ' FROM '.MAIN_DB_PREFIX.'societe as s';
327 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays)";
328 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typent)";
329 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)";
330 $sql .= ', '.MAIN_DB_PREFIX.'supplier_proposal as sp';
331 if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
332  $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (sp.rowid = ef.fk_object)";
333 }
334 if ($sall) {
335  $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'supplier_proposaldet as pd ON sp.rowid=pd.fk_supplier_proposal';
336 }
337 $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'user as u ON sp.fk_user_author = u.rowid';
338 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = sp.fk_projet";
339 // We'll need this table joined to the select in order to filter by sale
340 if ($search_sale > 0 || (empty($user->rights->societe->client->voir) && !$socid)) {
341  $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
342 }
343 if ($search_user > 0) {
344  $sql .= ", ".MAIN_DB_PREFIX."element_contact as c";
345  $sql .= ", ".MAIN_DB_PREFIX."c_type_contact as tc";
346 }
347 $sql .= ' WHERE sp.fk_soc = s.rowid';
348 $sql .= ' AND sp.entity IN ('.getEntity('supplier_proposal').')';
349 if (empty($user->rights->societe->client->voir) && !$socid) { //restriction
350  $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
351 }
352 if ($search_town) {
353  $sql .= natural_search('s.town', $search_town);
354 }
355 if ($search_zip) {
356  $sql .= natural_search("s.zip", $search_zip);
357 }
358 if ($search_state) {
359  $sql .= natural_search("state.nom", $search_state);
360 }
361 if ($search_country) {
362  $sql .= " AND s.fk_pays IN (".$db->sanitize($search_country).')';
363 }
364 if ($search_type_thirdparty != '' && $search_type_thirdparty > 0) {
365  $sql .= " AND s.fk_typent IN (".$db->sanitize($search_type_thirdparty).')';
366 }
367 if ($search_ref) {
368  $sql .= natural_search('sp.ref', $search_ref);
369 }
370 if (empty($arrayfields['s.name_alias']['checked']) && $search_societe) {
371  $sql .= natural_search(array("s.nom", "s.name_alias"), $search_societe);
372 } else {
373  if ($search_societe) {
374  $sql .= natural_search('s.nom', $search_societe);
375  }
376  if ($search_societe_alias) {
377  $sql .= natural_search('s.name_alias', $search_societe_alias);
378  }
379 }
380 if ($search_login) {
381  $sql .= natural_search(array('u.lastname', 'u.firstname', 'u.login'), $search_login);
382 }
383 if ($search_montant_ht) {
384  $sql .= natural_search('sp.total_ht', $search_montant_ht, 1);
385 }
386 if ($search_montant_vat != '') {
387  $sql .= natural_search("sp.total_tva", $search_montant_vat, 1);
388 }
389 if ($search_montant_ttc != '') {
390  $sql .= natural_search("sp.total_ttc", $search_montant_ttc, 1);
391 }
392 if ($search_multicurrency_code != '') {
393  $sql .= " AND sp.multicurrency_code = '".$db->escape($search_multicurrency_code)."'";
394 }
395 if ($search_multicurrency_tx != '') {
396  $sql .= natural_search('sp.multicurrency_tx', $search_multicurrency_tx, 1);
397 }
398 if ($search_multicurrency_montant_ht != '') {
399  $sql .= natural_search('sp.multicurrency_total_ht', $search_multicurrency_montant_ht, 1);
400 }
401 if ($search_multicurrency_montant_vat != '') {
402  $sql .= natural_search('sp.multicurrency_total_tva', $search_multicurrency_montant_vat, 1);
403 }
404 if ($search_multicurrency_montant_ttc != '') {
405  $sql .= natural_search('sp.multicurrency_total_ttc', $search_multicurrency_montant_ttc, 1);
406 }
407 if ($sall) {
408  $sql .= natural_search(array_keys($fieldstosearchall), $sall);
409 }
410 if ($socid) {
411  $sql .= ' AND s.rowid = '.((int) $socid);
412 }
413 if ($search_status >= 0 && $search_status != '') {
414  $sql .= ' AND sp.fk_statut IN ('.$db->sanitize($db->escape($search_status)).')';
415 }
416 if ($search_date_start) {
417  $sql .= " AND sp.date_livraison >= '".$db->idate($search_date_start)."'";
418 }
419 if ($search_date_end) {
420  $sql .= " AND sp.date_livraison <= '".$db->idate($search_date_end)."'";
421 }
422 if ($search_date_valid_start) {
423  $sql .= " AND sp.date_valid >= '".$db->idate($search_date_valid_start)."'";
424 }
425 if ($search_date_valid_end) {
426  $sql .= " AND sp.date_valid <= '".$db->idate($search_date_valid_end)."'";
427 }
428 if ($search_sale > 0) {
429  $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $search_sale);
430 }
431 if ($search_user > 0) {
432  $sql .= " AND c.fk_c_type_contact = tc.rowid AND tc.element='supplier_proposal' AND tc.source='internal' AND c.element_id = sp.rowid AND c.fk_socpeople = ".((int) $search_user);
433 }
434 // Search for tag/category ($searchCategoryProductList is an array of ID)
435 $searchCategoryProductOperator = -1;
436 $searchCategoryProductList = array($search_product_category);
437 if (!empty($searchCategoryProductList)) {
438  $searchCategoryProductSqlList = array();
439  $listofcategoryid = '';
440  foreach ($searchCategoryProductList as $searchCategoryProduct) {
441  if (intval($searchCategoryProduct) == -2) {
442  $searchCategoryProductSqlList[] = "NOT EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX."categorie_product as ck, ".MAIN_DB_PREFIX."supplier_proposaldet as sd WHERE sd.fk_supplier_proposal = sp.rowid AND sd.fk_product = ck.fk_product)";
443  } elseif (intval($searchCategoryProduct) > 0) {
444  if ($searchCategoryProductOperator == 0) {
445  $searchCategoryProductSqlList[] = " EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX."categorie_product as ck, ".MAIN_DB_PREFIX."supplier_proposaldet as sd WHERE sd.fk_supplier_proposal = sp.rowid AND sd.fk_product = ck.fk_product AND ck.fk_categorie = ".((int) $searchCategoryProduct).")";
446  } else {
447  $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryProduct);
448  }
449  }
450  }
451  if ($listofcategoryid) {
452  $searchCategoryProductSqlList[] = " EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX."categorie_product as ck, ".MAIN_DB_PREFIX."supplier_proposaldet as sd WHERE sd.fk_supplier_proposal = sp.rowid AND sd.fk_product = ck.fk_product AND ck.fk_categorie IN (".$db->sanitize($listofcategoryid)."))";
453  }
454  if ($searchCategoryProductOperator == 1) {
455  if (!empty($searchCategoryProductSqlList)) {
456  $sql .= " AND (".implode(' OR ', $searchCategoryProductSqlList).")";
457  }
458  } else {
459  if (!empty($searchCategoryProductSqlList)) {
460  $sql .= " AND (".implode(' AND ', $searchCategoryProductSqlList).")";
461  }
462  }
463 }
464 // Add where from extra fields
465 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
466 // Add where from hooks
467 $parameters = array();
468 $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
469 $sql .= $hookmanager->resPrint;
470 
471 $sql .= $db->order($sortfield, $sortorder);
472 $sql .= ', sp.ref DESC';
473 
474 // Count total nb of records
475 $nbtotalofrecords = '';
476 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
477  $resql = $db->query($sql);
478  $nbtotalofrecords = $db->num_rows($resql);
479  if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
480  $page = 0;
481  $offset = 0;
482  }
483 }
484 
485 $sql .= $db->plimit($limit + 1, $offset);
486 
487 $resql = $db->query($sql);
488 if ($resql) {
489  $objectstatic = new SupplierProposal($db);
490  $userstatic = new User($db);
491 
492  if ($socid > 0) {
493  $soc = new Societe($db);
494  $soc->fetch($socid);
495  $title = $langs->trans('SupplierProposals').' - '.$soc->name;
496  } else {
497  $title = $langs->trans('SupplierProposals');
498  }
499 
500  $num = $db->num_rows($resql);
501 
502  $arrayofselected = is_array($toselect) ? $toselect : array();
503 
504  if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $sall) {
505  $obj = $db->fetch_object($resql);
506 
507  $id = $obj->rowid;
508 
509  header("Location: ".DOL_URL_ROOT.'/supplier_proposal/card.php?id='.$id);
510  exit;
511  }
512 
513  // Output page
514  // --------------------------------------------------------------------
515 
516  llxHeader('', $title, $help_url);
517 
518  $param = '';
519  if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
520  $param .= '&contextpage='.urlencode($contextpage);
521  }
522  if ($limit > 0 && $limit != $conf->liste_limit) {
523  $param .= '&limit='.urlencode($limit);
524  }
525  if ($sall) {
526  $param .= '&sall='.urlencode($sall);
527  }
528  if ($search_date_startday) {
529  $param .= '&search_date_startday='.urlencode($search_date_startday);
530  }
531  if ($search_date_startmonth) {
532  $param .= '&search_date_startmonth='.urlencode($search_date_startmonth);
533  }
534  if ($search_date_startyear) {
535  $param .= '&search_date_startyear='.urlencode($search_date_startyear);
536  }
537  if ($search_date_endday) {
538  $param .= '&search_date_endday='.urlencode($search_date_endday);
539  }
540  if ($search_date_endmonth) {
541  $param .= '&search_date_endmonth='.urlencode($search_date_endmonth);
542  }
543  if ($search_date_endyear) {
544  $param .= '&search_date_endyear='.urlencode($search_date_endyear);
545  }
546  if ($search_date_valid_startday) {
547  $param .= '&search_date_valid_startday='.urlencode($search_date_valid_startday);
548  }
549  if ($search_date_valid_startmonth) {
550  $param .= '&search_date_valid_startmonth='.urlencode($search_date_valid_startmonth);
551  }
552  if ($search_date_valid_startyear) {
553  $param .= '&search_date_valid_startyear='.urlencode($search_date_valid_startyear);
554  }
555  if ($search_date_valid_endday) {
556  $param .= '&search_date_valid_endday='.urlencode($search_date_valid_endday);
557  }
558  if ($search_date_valid_endmonth) {
559  $param .= '&search_date_valid_endmonth='.urlencode($search_date_valid_endmonth);
560  }
561  if ($search_date_valid_endyear) {
562  $param .= '&search_date_valid_endyear='.urlencode($search_date_valid_endyear);
563  }
564  if ($search_ref) {
565  $param .= '&search_ref='.urlencode($search_ref);
566  }
567  if ($search_societe) {
568  $param .= '&search_societe='.urlencode($search_societe);
569  }
570  if ($search_societe_alias) {
571  $param .= '&search_societe_alias='.urlencode($search_societe_alias);
572  }
573  if ($search_user > 0) {
574  $param .= '&search_user='.urlencode($search_user);
575  }
576  if ($search_sale > 0) {
577  $param .= '&search_sale='.urlencode($search_sale);
578  }
579  if ($search_montant_ht) {
580  $param .= '&search_montant_ht='.urlencode($search_montant_ht);
581  }
582  if ($search_multicurrency_code != '') {
583  $param .= '&search_multicurrency_code='.urlencode($search_multicurrency_code);
584  }
585  if ($search_multicurrency_tx != '') {
586  $param .= '&search_multicurrency_tx='.urlencode($search_multicurrency_tx);
587  }
588  if ($search_multicurrency_montant_ht != '') {
589  $param .= '&search_multicurrency_montant_ht='.urlencode($search_multicurrency_montant_ht);
590  }
591  if ($search_multicurrency_montant_vat != '') {
592  $param .= '&search_multicurrency_montant_vat='.urlencode($search_multicurrency_montant_vat);
593  }
594  if ($search_multicurrency_montant_ttc != '') {
595  $param .= '&search_multicurrency_montant_ttc='.urlencode($search_multicurrency_montant_ttc);
596  }
597  if ($search_login) {
598  $param .= '&search_login='.urlencode($search_login);
599  }
600  if ($search_town) {
601  $param .= '&search_town='.urlencode($search_town);
602  }
603  if ($search_zip) {
604  $param .= '&search_zip='.urlencode($search_zip);
605  }
606  if ($socid > 0) {
607  $param .= '&socid='.urlencode($socid);
608  }
609  if ($search_status != '') {
610  $param .= '&search_status='.urlencode($search_status);
611  }
612  if ($optioncss != '') {
613  $param .= '&optioncss='.urlencode($optioncss);
614  }
615  if ($search_type_thirdparty != '' && $search_type_thirdparty > 0) {
616  $param .= '&search_type_thirdparty='.urlencode($search_type_thirdparty);
617  }
618  // Add $param from extra fields
619  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
620 
621  // List of mass actions available
622  $arrayofmassactions = array(
623  'generate_doc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("ReGeneratePDF"),
624  'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
625  //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
626  );
627  if ($user->rights->supplier_proposal->supprimer) {
628  $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
629  }
630  if (in_array($massaction, array('presend', 'predelete'))) {
631  $arrayofmassactions = array();
632  }
633  $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
634 
635  $url = DOL_URL_ROOT.'/supplier_proposal/card.php?action=create';
636  if (!empty($socid)) {
637  $url .= '&socid='.$socid;
638  }
639  $newcardbutton = dolGetButtonTitle($langs->trans('NewAskPrice'), '', 'fa fa-plus-circle', $url, '', $user->rights->supplier_proposal->creer);
640 
641  // Fields title search
642  print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
643  if ($optioncss != '') {
644  print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
645  }
646  print '<input type="hidden" name="token" value="'.newToken().'">';
647  print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
648  print '<input type="hidden" name="action" value="list">';
649  print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
650  print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
651 
652  print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'supplier_proposal', 0, $newcardbutton, '', $limit, 0, 0, 1);
653 
654  $topicmail = "SendSupplierProposalRef";
655  $modelmail = "supplier_proposal_send";
656  $objecttmp = new SupplierProposal($db);
657  $trackid = 'spro'.$object->id;
658  include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
659 
660  if ($sall) {
661  foreach ($fieldstosearchall as $key => $val) {
662  $fieldstosearchall[$key] = $langs->trans($val);
663  }
664  print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'</div>';
665  }
666 
667  $i = 0;
668 
669  $moreforfilter = '';
670 
671  // If the user can view prospects other than his'
672  if ($user->rights->user->user->lire) {
673  $langs->load("commercial");
674  $moreforfilter .= '<div class="divsearchfield">';
675  $tmptitle = $langs->trans('ThirdPartiesOfSaleRepresentative');
676  $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, $tmptitle, 'maxwidth250 widthcentpercentminusx');
677  $moreforfilter .= '</div>';
678  }
679  // If the user can view prospects other than his'
680  if ($user->rights->user->user->lire) {
681  $moreforfilter .= '<div class="divsearchfield">';
682  $tmptitle = $langs->trans('LinkedToSpecificUsers');
683  $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$form->select_dolusers($search_user, 'search_user', $tmptitle, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth250 widthcentpercentminusx');
684  $moreforfilter .= '</div>';
685  }
686  // If the user can view products
687  if (isModEnabled('categorie') && $user->rights->categorie->lire && ($user->rights->produit->lire || $user->rights->service->lire)) {
688  include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
689  $moreforfilter .= '<div class="divsearchfield">';
690  $tmptitle = $langs->trans('IncludingProductWithTag');
691  $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, null, 'parent', null, null, 1);
692  $moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"').$form->selectarray('search_product_category', $cate_arbo, $search_product_category, $tmptitle, 0, 0, '', 0, 0, 0, 0, 'maxwidth300 widthcentpercentminusx', 1);
693  $moreforfilter .= '</div>';
694  }
695  $parameters = array();
696  $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook
697  if (empty($reshook)) {
698  $moreforfilter .= $hookmanager->resPrint;
699  } else {
700  $moreforfilter = $hookmanager->resPrint;
701  }
702 
703  if (!empty($moreforfilter)) {
704  print '<div class="liste_titre liste_titre_bydiv centpercent">';
705  print $moreforfilter;
706  print '</div>';
707  }
708 
709  $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
710  $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN', '')); // This also change content of $arrayfields
711  $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
712 
713  print '<div class="div-table-responsive">';
714  print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
715 
716  // Fields title search
717  // --------------------------------------------------------------------
718  print '<tr class="liste_titre_filter">';
719  // Action column
720  if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
721  print '<td class="liste_titre maxwidthsearch">';
722  $searchpicto = $form->showFilterButtons('left');
723  print $searchpicto;
724  print '</td>';
725  }
726  if (!empty($arrayfields['sp.ref']['checked'])) {
727  print '<td class="liste_titre">';
728  print '<input class="flat" size="6" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
729  print '</td>';
730  }
731  if (!empty($arrayfields['s.nom']['checked'])) {
732  print '<td class="liste_titre left">';
733  print '<input class="flat" type="text" size="12" name="search_societe" value="'.dol_escape_htmltag($search_societe).'">';
734  print '</td>';
735  }
736  if (!empty($arrayfields['s.name_alias']['checked'])) {
737  print '<td class="liste_titre left">';
738  print '<input class="flat" type="text" size="12" name="search_societe_alias" value="'.dol_escape_htmltag($search_societe_alias).'">';
739  print '</td>';
740  }
741  if (!empty($arrayfields['s.town']['checked'])) {
742  print '<td class="liste_titre"><input class="flat" type="text" size="6" name="search_town" value="'.$search_town.'"></td>';
743  }
744  if (!empty($arrayfields['s.zip']['checked'])) {
745  print '<td class="liste_titre"><input class="flat" type="text" size="4" name="search_zip" value="'.$search_zip.'"></td>';
746  }
747  // State
748  if (!empty($arrayfields['state.nom']['checked'])) {
749  print '<td class="liste_titre">';
750  print '<input class="flat" size="4" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).'">';
751  print '</td>';
752  }
753  // Country
754  if (!empty($arrayfields['country.code_iso']['checked'])) {
755  print '<td class="liste_titre center">';
756  print $form->select_country($search_country, 'search_country', '', 0, 'minwidth100imp maxwidth100');
757  print '</td>';
758  }
759  // Company type
760  if (!empty($arrayfields['typent.code']['checked'])) {
761  print '<td class="liste_titre maxwidthonsmartphone center">';
762  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);
763  print '</td>';
764  }
765  // Date
766  if (!empty($arrayfields['sp.date_valid']['checked'])) {
767  print '<td class="liste_titre center">';
768  print '<div class="nowrap">';
769  print $form->selectDate($search_date_valid_start ? $search_date_valid_start : -1, 'search_date_valid_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
770  print '</div>';
771  print '<div class="nowrap">';
772  print $form->selectDate($search_date_valid_end ? $search_date_valid_end : -1, 'search_date_valid_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
773  print '</div>';
774  print '</td>';
775  }
776  // Date
777  if (!empty($arrayfields['sp.date_livraison']['checked'])) {
778  print '<td class="liste_titre center">';
779  print '<div class="nowrap">';
780  print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
781  print '</div>';
782  print '<div class="nowrap">';
783  print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
784  print '</div>';
785  print '</td>';
786  }
787 
788  if (!empty($arrayfields['sp.total_ht']['checked'])) {
789  // Amount
790  print '<td class="liste_titre right">';
791  print '<input class="flat" type="text" size="5" name="search_montant_ht" value="'.dol_escape_htmltag($search_montant_ht).'">';
792  print '</td>';
793  }
794  if (!empty($arrayfields['sp.total_tva']['checked'])) {
795  // Amount
796  print '<td class="liste_titre right">';
797  print '<input class="flat" type="text" size="5" name="search_montant_vat" value="'.dol_escape_htmltag($search_montant_vat).'">';
798  print '</td>';
799  }
800  if (!empty($arrayfields['sp.total_ttc']['checked'])) {
801  // Amount
802  print '<td class="liste_titre right">';
803  print '<input class="flat" type="text" size="5" name="search_montant_ttc" value="'.dol_escape_htmltag($search_montant_ttc).'">';
804  print '</td>';
805  }
806  if (!empty($arrayfields['sp.multicurrency_code']['checked'])) {
807  // Currency
808  print '<td class="liste_titre">';
809  print $form->selectMultiCurrency($search_multicurrency_code, 'search_multicurrency_code', 1);
810  print '</td>';
811  }
812  if (!empty($arrayfields['sp.multicurrency_tx']['checked'])) {
813  // Currency rate
814  print '<td class="liste_titre">';
815  print '<input class="flat" type="text" size="4" name="search_multicurrency_tx" value="'.dol_escape_htmltag($search_multicurrency_tx).'">';
816  print '</td>';
817  }
818  if (!empty($arrayfields['sp.multicurrency_total_ht']['checked'])) {
819  // Amount
820  print '<td class="liste_titre right">';
821  print '<input class="flat" type="text" size="4" name="search_multicurrency_montant_ht" value="'.dol_escape_htmltag($search_multicurrency_montant_ht).'">';
822  print '</td>';
823  }
824  if (!empty($arrayfields['sp.multicurrency_total_vat']['checked'])) {
825  // Amount
826  print '<td class="liste_titre right">';
827  print '<input class="flat" type="text" size="4" name="search_multicurrency_montant_vat" value="'.dol_escape_htmltag($search_multicurrency_montant_vat).'">';
828  print '</td>';
829  }
830  if (!empty($arrayfields['sp.multicurrency_total_ttc']['checked'])) {
831  // Amount
832  print '<td class="liste_titre right">';
833  print '<input class="flat" type="text" size="4" name="search_multicurrency_montant_ttc" value="'.dol_escape_htmltag($search_multicurrency_montant_ttc).'">';
834  print '</td>';
835  }
836  if (!empty($arrayfields['u.login']['checked'])) {
837  // Author
838  print '<td class="liste_titre center">';
839  print '<input class="flat" size="4" type="text" name="search_login" value="'.dol_escape_htmltag($search_login).'">';
840  print '</td>';
841  }
842  // Extra fields
843  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
844  // Fields from hook
845  $parameters = array('arrayfields'=>$arrayfields);
846  $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
847  print $hookmanager->resPrint;
848  // Date creation
849  if (!empty($arrayfields['sp.datec']['checked'])) {
850  print '<td class="liste_titre">';
851  print '</td>';
852  }
853  // Date modification
854  if (!empty($arrayfields['sp.tms']['checked'])) {
855  print '<td class="liste_titre">';
856  print '</td>';
857  }
858  // Status
859  if (!empty($arrayfields['sp.fk_statut']['checked'])) {
860  print '<td class="liste_titre right">';
861  $formpropal->selectProposalStatus($search_status, 1, 0, 1, 'supplier', 'search_status', 'minwidth75imp onrightofpage');
862  print '</td>';
863  }
864  // Action column
865  if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
866  print '<td class="liste_titre maxwidthsearch">';
867  $searchpicto = $form->showFilterButtons();
868  print $searchpicto;
869  print '</td>';
870  }
871 
872  print "</tr>\n";
873 
874  // Fields title
875  print '<tr class="liste_titre">';
876  if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
877  print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
878  }
879  if (!empty($arrayfields['sp.ref']['checked'])) {
880  print_liste_field_titre($arrayfields['sp.ref']['label'], $_SERVER["PHP_SELF"], 'sp.ref', '', $param, '', $sortfield, $sortorder);
881  }
882  if (!empty($arrayfields['s.nom']['checked'])) {
883  print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], 's.nom', '', $param, '', $sortfield, $sortorder);
884  }
885  if (!empty($arrayfields['s.name_alias']['checked'])) {
886  print_liste_field_titre($arrayfields['s.name_alias']['label'], $_SERVER["PHP_SELF"], 's.name_alias', '', $param, '', $sortfield, $sortorder);
887  }
888  if (!empty($arrayfields['s.town']['checked'])) {
889  print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], 's.town', '', $param, '', $sortfield, $sortorder);
890  }
891  if (!empty($arrayfields['s.zip']['checked'])) {
892  print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], 's.zip', '', $param, '', $sortfield, $sortorder);
893  }
894  if (!empty($arrayfields['state.nom']['checked'])) {
895  print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder);
896  }
897  if (!empty($arrayfields['country.code_iso']['checked'])) {
898  print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, '', $sortfield, $sortorder, 'center ');
899  }
900  if (!empty($arrayfields['typent.code']['checked'])) {
901  print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, '', $sortfield, $sortorder, 'center ');
902  }
903  if (!empty($arrayfields['sp.date_valid']['checked'])) {
904  print_liste_field_titre($arrayfields['sp.date_valid']['label'], $_SERVER["PHP_SELF"], 'sp.date_valid', '', $param, '', $sortfield, $sortorder, 'center ');
905  }
906  if (!empty($arrayfields['sp.date_livraison']['checked'])) {
907  print_liste_field_titre($arrayfields['sp.date_livraison']['label'], $_SERVER["PHP_SELF"], 'sp.date_livraison', '', $param, '', $sortfield, $sortorder, 'center ');
908  }
909  if (!empty($arrayfields['sp.total_ht']['checked'])) {
910  print_liste_field_titre($arrayfields['sp.total_ht']['label'], $_SERVER["PHP_SELF"], 'sp.total_ht', '', $param, '', $sortfield, $sortorder, 'right ');
911  }
912  if (!empty($arrayfields['sp.total_tva']['checked'])) {
913  print_liste_field_titre($arrayfields['sp.total_tva']['label'], $_SERVER["PHP_SELF"], 'sp.total_tva', '', $param, '', $sortfield, $sortorder, 'right ');
914  }
915  if (!empty($arrayfields['sp.total_ttc']['checked'])) {
916  print_liste_field_titre($arrayfields['sp.total_ttc']['label'], $_SERVER["PHP_SELF"], 'sp.total_ttc', '', $param, '', $sortfield, $sortorder, 'right ');
917  }
918  if (!empty($arrayfields['sp.multicurrency_code']['checked'])) {
919  print_liste_field_titre($arrayfields['sp.multicurrency_code']['label'], $_SERVER['PHP_SELF'], 'sp.multicurrency_code', '', $param, '', $sortfield, $sortorder);
920  }
921  if (!empty($arrayfields['sp.multicurrency_tx']['checked'])) {
922  print_liste_field_titre($arrayfields['sp.multicurrency_tx']['label'], $_SERVER['PHP_SELF'], 'sp.multicurrency_tx', '', $param, '', $sortfield, $sortorder);
923  }
924  if (!empty($arrayfields['sp.multicurrency_total_ht']['checked'])) {
925  print_liste_field_titre($arrayfields['sp.multicurrency_total_ht']['label'], $_SERVER['PHP_SELF'], 'sp.multicurrency_total_ht', '', $param, 'class="right"', $sortfield, $sortorder);
926  }
927  if (!empty($arrayfields['sp.multicurrency_total_vat']['checked'])) {
928  print_liste_field_titre($arrayfields['sp.multicurrency_total_vat']['label'], $_SERVER['PHP_SELF'], 'sp.multicurrency_total_tva', '', $param, 'class="right"', $sortfield, $sortorder);
929  }
930  if (!empty($arrayfields['sp.multicurrency_total_ttc']['checked'])) {
931  print_liste_field_titre($arrayfields['sp.multicurrency_total_ttc']['label'], $_SERVER['PHP_SELF'], 'sp.multicurrency_total_ttc', '', $param, 'class="right"', $sortfield, $sortorder);
932  }
933  if (!empty($arrayfields['u.login']['checked'])) {
934  print_liste_field_titre($arrayfields['u.login']['label'], $_SERVER["PHP_SELF"], 'u.login', '', $param, '', $sortfield, $sortorder, 'center ');
935  }
936  // Extra fields
937  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
938  // Hook fields
939  $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
940  $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
941  print $hookmanager->resPrint;
942  if (!empty($arrayfields['sp.datec']['checked'])) {
943  print_liste_field_titre($arrayfields['sp.datec']['label'], $_SERVER["PHP_SELF"], "sp.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
944  }
945  if (!empty($arrayfields['sp.tms']['checked'])) {
946  print_liste_field_titre($arrayfields['sp.tms']['label'], $_SERVER["PHP_SELF"], "sp.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap');
947  }
948  if (!empty($arrayfields['sp.fk_statut']['checked'])) {
949  print_liste_field_titre($arrayfields['sp.fk_statut']['label'], $_SERVER["PHP_SELF"], "sp.fk_statut", "", $param, '', $sortfield, $sortorder, 'right ');
950  }
951  if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
952  print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
953  }
954  print '</tr>'."\n";
955 
956  $now = dol_now();
957  $i = 0;
958  $total = 0;
959  $subtotal = 0;
960  $totalarray = array();
961  $totalarray['nbfield'] = 0;
962  $totalarray['val'] = array();
963  $totalarray['val']['sp.total_ht'] = 0;
964  $totalarray['val']['sp.total_tva'] = 0;
965  $totalarray['val']['sp.total_ttc'] = 0;
966  while ($i < min($num, $limit)) {
967  $obj = $db->fetch_object($resql);
968 
969  $objectstatic->id = $obj->rowid;
970  $objectstatic->ref = $obj->ref;
971  $objectstatic->note_public = $obj->note_public;
972  $objectstatic->note_private = $obj->note_private;
973  $objectstatic->status = $obj->status;
974 
975  // Company
976  $companystatic->id = $obj->socid;
977  $companystatic->name = $obj->name;
978  $companystatic->name_alias = $obj->alias;
979  $companystatic->client = $obj->client;
980  $companystatic->code_client = $obj->code_client;
981 
982  print '<tr class="oddeven">';
983  // Action column
984  if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
985  print '<td class="nowrap center">';
986  if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
987  $selected = 0;
988  if (in_array($obj->rowid, $arrayofselected)) {
989  $selected = 1;
990  }
991  print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
992  }
993  print '</td>';
994  }
995  if (!empty($arrayfields['sp.ref']['checked'])) {
996  print '<td class="nowraponall">';
997 
998  print '<table class="nobordernopadding"><tr class="nocellnopadd">';
999  // Picto + Ref
1000  print '<td class="nobordernopadding nowraponall">';
1001  print $objectstatic->getNomUrl(1, '', '', 0, -1, 1);
1002  print '</td>';
1003  // Warning
1004  $warnornote = '';
1005  //if ($obj->fk_statut == 1 && $db->jdate($obj->date_valid) < ($now - $conf->supplier_proposal->warning_delay)) $warnornote .= img_warning($langs->trans("Late"));
1006  if ($warnornote) {
1007  print '<td style="min-width: 20px" class="nobordernopadding nowrap">';
1008  print $warnornote;
1009  print '</td>';
1010  }
1011  // Other picto tool
1012  print '<td width="16" class="right nobordernopadding hideonsmartphone">';
1013  $filename = dol_sanitizeFileName($obj->ref);
1014  $filedir = $conf->supplier_proposal->dir_output.'/'.dol_sanitizeFileName($obj->ref);
1015  $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->rowid;
1016  print $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir);
1017  print '</td></tr></table>';
1018 
1019  print "</td>\n";
1020  if (!$i) {
1021  $totalarray['nbfield']++;
1022  }
1023  }
1024 
1025  // Thirdparty
1026  if (!empty($arrayfields['s.nom']['checked'])) {
1027  print '<td class="tdoverflowmax200">';
1028  print $companystatic->getNomUrl(1, 'supplier', 0, 0, -1, empty($arrayfields['s.name_alias']['checked']) ? 0 : 1);
1029  print '</td>';
1030  if (!$i) {
1031  $totalarray['nbfield']++;
1032  }
1033  }
1034 
1035  // Alias
1036  if (!empty($arrayfields['s.name_alias']['checked'])) {
1037  print '<td class="tdoverflowmax200">';
1038  print $companystatic->name_alias;
1039  print '</td>';
1040  if (!$i) {
1041  $totalarray['nbfield']++;
1042  }
1043  }
1044 
1045  // Town
1046  if (!empty($arrayfields['s.town']['checked'])) {
1047  print '<td class="nocellnopadd">';
1048  print $obj->town;
1049  print '</td>';
1050  if (!$i) {
1051  $totalarray['nbfield']++;
1052  }
1053  }
1054  // Zip
1055  if (!empty($arrayfields['s.zip']['checked'])) {
1056  print '<td class="nocellnopadd">';
1057  print $obj->zip;
1058  print '</td>';
1059  if (!$i) {
1060  $totalarray['nbfield']++;
1061  }
1062  }
1063  // State
1064  if (!empty($arrayfields['state.nom']['checked'])) {
1065  print "<td>".$obj->state_name."</td>\n";
1066  if (!$i) {
1067  $totalarray['nbfield']++;
1068  }
1069  }
1070  // Country
1071  if (!empty($arrayfields['country.code_iso']['checked'])) {
1072  print '<td class="center">';
1073  $tmparray = getCountry($obj->fk_pays, 'all');
1074  print $tmparray['label'];
1075  print '</td>';
1076  if (!$i) {
1077  $totalarray['nbfield']++;
1078  }
1079  }
1080  // Type ent
1081  if (!empty($arrayfields['typent.code']['checked'])) {
1082  print '<td class="center">';
1083  if (empty($typenArray) || !is_array($typenArray) || count($typenArray) == 0) {
1084  $typenArray = $formcompany->typent_array(1);
1085  }
1086  print $typenArray[$obj->typent_code];
1087  print '</td>';
1088  if (!$i) {
1089  $totalarray['nbfield']++;
1090  }
1091  }
1092 
1093  // Date proposal
1094  if (!empty($arrayfields['sp.date_valid']['checked'])) {
1095  print '<td class="center">';
1096  print dol_print_date($db->jdate($obj->date_valid), 'day');
1097  print "</td>\n";
1098  if (!$i) {
1099  $totalarray['nbfield']++;
1100  }
1101  }
1102 
1103  // Date delivery
1104  if (!empty($arrayfields['sp.date_livraison']['checked'])) {
1105  print '<td class="center">';
1106  print dol_print_date($db->jdate($obj->dp), 'day');
1107  print "</td>\n";
1108  if (!$i) {
1109  $totalarray['nbfield']++;
1110  }
1111  }
1112 
1113  // Amount HT
1114  if (!empty($arrayfields['sp.total_ht']['checked'])) {
1115  print '<td class="right"><span class="amount">'.price($obj->total_ht)."</span></td>\n";
1116  if (!$i) {
1117  $totalarray['nbfield']++;
1118  }
1119  if (!$i) {
1120  $totalarray['pos'][$totalarray['nbfield']] = 'sp.total_ht';
1121  }
1122  $totalarray['val']['sp.total_ht'] += $obj->total_ht;
1123  }
1124  // Amount VAT
1125  if (!empty($arrayfields['sp.total_tva']['checked'])) {
1126  print '<td class="right"><span class="amount">'.price($obj->total_tva)."</span></td>\n";
1127  if (!$i) {
1128  $totalarray['nbfield']++;
1129  }
1130  if (!$i) {
1131  $totalarray['pos'][$totalarray['nbfield']] = 'sp.total_tva';
1132  }
1133  $totalarray['val']['sp.total_tva'] += $obj->total_tva;
1134  }
1135  // Amount TTC
1136  if (!empty($arrayfields['sp.total_ttc']['checked'])) {
1137  print '<td class="right"><span class="amount">'.price($obj->total_ttc)."</span></td>\n";
1138  if (!$i) {
1139  $totalarray['nbfield']++;
1140  }
1141  if (!$i) {
1142  $totalarray['pos'][$totalarray['nbfield']] = 'sp.total_ttc';
1143  }
1144  $totalarray['val']['sp.total_ttc'] += $obj->total_ttc;
1145  }
1146 
1147  // Currency
1148  if (!empty($arrayfields['sp.multicurrency_code']['checked'])) {
1149  print '<td class="nowrap">'.$obj->multicurrency_code.' - '.$langs->trans('Currency'.$obj->multicurrency_code)."</td>\n";
1150  if (!$i) {
1151  $totalarray['nbfield']++;
1152  }
1153  }
1154 
1155  // Currency rate
1156  if (!empty($arrayfields['sp.multicurrency_tx']['checked'])) {
1157  print '<td class="nowrap">';
1158  $form->form_multicurrency_rate($_SERVER['PHP_SELF'].'?id='.$obj->rowid, $obj->multicurrency_tx, 'none', $obj->multicurrency_code);
1159  print "</td>\n";
1160  if (!$i) {
1161  $totalarray['nbfield']++;
1162  }
1163  }
1164  // Amount HT
1165  if (!empty($arrayfields['sp.multicurrency_total_ht']['checked'])) {
1166  print '<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_ht)."</span></td>\n";
1167  if (!$i) {
1168  $totalarray['nbfield']++;
1169  }
1170  }
1171  // Amount VAT
1172  if (!empty($arrayfields['sp.multicurrency_total_vat']['checked'])) {
1173  print '<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_vat)."</span></td>\n";
1174  if (!$i) {
1175  $totalarray['nbfield']++;
1176  }
1177  }
1178  // Amount TTC
1179  if (!empty($arrayfields['sp.multicurrency_total_ttc']['checked'])) {
1180  print '<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_ttc)."</span></td>\n";
1181  if (!$i) {
1182  $totalarray['nbfield']++;
1183  }
1184  }
1185 
1186  $userstatic->id = $obj->fk_user_author;
1187  $userstatic->login = $obj->login;
1188  $userstatic->status = $obj->ustatus;
1189  $userstatic->lastname = $obj->name;
1190  $userstatic->firstname = $obj->firstname;
1191  $userstatic->photo = $obj->photo;
1192  $userstatic->admin = $obj->admin;
1193  $userstatic->ref = $obj->fk_user_author;
1194  $userstatic->employee = $obj->employee;
1195  $userstatic->email = $obj->uemail;
1196 
1197  // Author
1198  if (!empty($arrayfields['u.login']['checked'])) {
1199  print '<td class="center">';
1200  if ($userstatic->id > 0) {
1201  print $userstatic->getNomUrl(-1, '', 0, 0, 24, 1, 'login', '', 1);
1202  } else {
1203  print '&nbsp;';
1204  }
1205  print "</td>\n";
1206  if (!$i) {
1207  $totalarray['nbfield']++;
1208  }
1209  }
1210 
1211  // Extra fields
1212  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
1213  // Fields from hook
1214  $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
1215  $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook
1216  print $hookmanager->resPrint;
1217  // Date creation
1218  if (!empty($arrayfields['sp.datec']['checked'])) {
1219  print '<td class="center nowrap">';
1220  print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser');
1221  print '</td>';
1222  if (!$i) {
1223  $totalarray['nbfield']++;
1224  }
1225  }
1226  // Date modification
1227  if (!empty($arrayfields['sp.tms']['checked'])) {
1228  print '<td class="center nowrap">';
1229  print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser');
1230  print '</td>';
1231  if (!$i) {
1232  $totalarray['nbfield']++;
1233  }
1234  }
1235  // Status
1236  if (!empty($arrayfields['sp.fk_statut']['checked'])) {
1237  print '<td class="right">'.$objectstatic->getLibStatut(5)."</td>\n";
1238  if (!$i) {
1239  $totalarray['nbfield']++;
1240  }
1241  }
1242 
1243  // Action column
1244  if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1245  print '<td class="nowrap center">';
1246  if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
1247  $selected = 0;
1248  if (in_array($obj->rowid, $arrayofselected)) {
1249  $selected = 1;
1250  }
1251  print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
1252  }
1253  print '</td>';
1254  }
1255  if (!$i) {
1256  $totalarray['nbfield']++;
1257  }
1258 
1259  print "</tr>\n";
1260 
1261  $total += $obj->total_ht;
1262  $subtotal += $obj->total_ht;
1263 
1264  $i++;
1265  }
1266 
1267  // Show total line
1268  include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
1269 
1270  // If no record found
1271  if ($num == 0) {
1272  $colspan = 1;
1273  foreach ($arrayfields as $key => $val) {
1274  if (!empty($val['checked'])) {
1275  $colspan++;
1276  }
1277  }
1278  print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
1279  }
1280 
1281  $db->free($resql);
1282 
1283  $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql);
1284  $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook
1285  print $hookmanager->resPrint;
1286 
1287  print '</table>'."\n";
1288  print '</div>'."\n";
1289 
1290  print '</form>'."\n";
1291 
1292  $hidegeneratedfilelistifempty = 1;
1293  if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) {
1294  $hidegeneratedfilelistifempty = 0;
1295  }
1296 
1297  // Show list of available documents
1298  $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
1299  $urlsource .= str_replace('&amp;', '&', $param);
1300 
1301  $filedir = $diroutputmassaction;
1302 
1303  $genallowed = $user->rights->supplier_proposal->lire;
1304  $delallowed = $user->rights->supplier_proposal->creer;
1305 
1306  print $formfile->showdocuments('massfilesarea_supplier_proposal', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
1307 } else {
1308  dol_print_error($db);
1309 }
1310 
1311 // End of page
1312 llxFooter();
1313 $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
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 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.
Class to manage generation of HTML components for proposal management.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage price ask supplier.
Class to manage Dolibarr users.
Definition: user.class.php:47
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...
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.
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.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by second index function, which produces ascending (default) or descending output...
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.
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.