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