dolibarr  13.0.2
list.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2001-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2004-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  *
15  * This program is free software; you can redistribute it and/or modify
16  * it under the terms of the GNU General Public License as published by
17  * the Free Software Foundation; either version 3 of the License, or
18  * (at your option) any later version.
19  *
20  * This program is distributed in the hope that it will be useful,
21  * but WITHOUT ANY WARRANTY; without even the implied warranty of
22  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23  * GNU General Public License for more details.
24  *
25  * You should have received a copy of the GNU General Public License
26  * along with this program. If not, see <https://www.gnu.org/licenses/>.
27  */
28 
35 require '../main.inc.php';
36 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
37 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
38 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
39 require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
40 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formpropal.class.php';
41 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
42 require_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class.php';
43 if (!empty($conf->projet->enabled))
44  require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
45 
46 // Load translation files required by the page
47 $langs->loadLangs(array('companies', 'propal', 'supplier_proposal', 'compta', 'bills', 'orders', 'products'));
48 
49 $socid = GETPOST('socid', 'int');
50 
51 $action = GETPOST('action', 'aZ09');
52 $massaction = GETPOST('massaction', 'alpha');
53 $show_files = GETPOST('show_files', 'int');
54 $confirm = GETPOST('confirm', 'alpha');
55 $toselect = GETPOST('toselect', 'array');
56 $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'supplierproposallist';
57 
58 $search_user = GETPOST('search_user', 'int');
59 $search_sale = GETPOST('search_sale', 'int');
60 $search_ref = GETPOST('sf_ref') ?GETPOST('sf_ref', 'alpha') : GETPOST('search_ref', 'alpha');
61 $search_societe = GETPOST('search_societe', 'alpha');
62 $search_login = GETPOST('search_login', 'alpha');
63 $search_town = GETPOST('search_town', 'alpha');
64 $search_zip = GETPOST('search_zip', 'alpha');
65 $search_state = GETPOST("search_state");
66 $search_country = GETPOST("search_country", 'int');
67 $search_type_thirdparty = GETPOST("search_type_thirdparty", 'int');
68 $search_montant_ht = GETPOST('search_montant_ht', 'alpha');
69 $search_montant_vat = GETPOST('search_montant_vat', 'alpha');
70 $search_montant_ttc = GETPOST('search_montant_ttc', 'alpha');
71 $search_multicurrency_code = GETPOST('search_multicurrency_code', 'alpha');
72 $search_multicurrency_tx = GETPOST('search_multicurrency_tx', 'alpha');
73 $search_multicurrency_montant_ht = GETPOST('search_multicurrency_montant_ht', 'alpha');
74 $search_multicurrency_montant_vat = GETPOST('search_multicurrency_montant_vat', 'alpha');
75 $search_multicurrency_montant_ttc = GETPOST('search_multicurrency_montant_ttc', 'alpha');
76 $search_status = GETPOST('search_status', 'int');
77 
78 $object_statut = $db->escape(GETPOST('supplier_proposal_statut'));
79 $search_btn = GETPOST('button_search', 'alpha');
80 $search_remove_btn = GETPOST('button_removefilter', 'alpha');
81 
82 $sall = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml'));
83 
84 $mesg = (GETPOST("msg") ? GETPOST("msg") : GETPOST("mesg"));
85 $year = GETPOST("year");
86 $month = GETPOST("month");
87 $day = GETPOST("day");
88 $yearvalid = GETPOST("yearvalid");
89 $monthvalid = GETPOST("monthvalid");
90 $dayvalid = GETPOST("dayvalid");
91 
92 $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
93 $sortfield = GETPOST("sortfield", 'alpha');
94 $sortorder = GETPOST("sortorder", 'alpha');
95 $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
96 if (empty($page) || $page == -1 || !empty($search_btn) || !empty($search_remove_btn) || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1
97 $offset = $limit * $page;
98 $pageprev = $page - 1;
99 $pagenext = $page + 1;
100 if (!$sortfield) $sortfield = 'sp.date_livraison';
101 if (!$sortorder) $sortorder = 'DESC';
102 
103 if ($object_statut != '') $search_status = $object_statut;
104 
105 // Nombre de ligne pour choix de produit/service predefinis
106 $NBLINES = 4;
107 
108 // Security check
109 $module = 'supplier_proposal';
110 $dbtable = '';
111 $objectid = '';
112 if (!empty($user->socid)) $socid = $user->socid;
113 if (!empty($socid))
114 {
115  $objectid = $socid;
116  $module = 'societe';
117  $dbtable = '&societe';
118 }
119 $result = restrictedArea($user, $module, $objectid, $dbtable);
120 
121 $diroutputmassaction = $conf->supplier_proposal->dir_output.'/temp/massgeneration/'.$user->id;
122 
123 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
124 $object = new SupplierProposal($db);
125 $hookmanager->initHooks(array('supplier_proposallist'));
126 $extrafields = new ExtraFields($db);
127 
128 // fetch optionals attributes and labels
129 $extrafields->fetch_name_optionals_label($object->table_element);
130 
131 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
132 
133 
134 // List of fields to search into when doing a "search in all"
135 $fieldstosearchall = array(
136  'sp.ref'=>'Ref',
137  's.nom'=>'Supplier',
138  'pd.description'=>'Description',
139  'sp.note_public'=>'NotePublic',
140 );
141 if (empty($user->socid)) $fieldstosearchall["p.note_private"] = "NotePrivate";
142 
143 $checkedtypetiers = 0;
144 $arrayfields = array(
145  'sp.ref'=>array('label'=>$langs->trans("Ref"), 'checked'=>1),
146  's.nom'=>array('label'=>$langs->trans("Supplier"), 'checked'=>1),
147  's.town'=>array('label'=>$langs->trans("Town"), 'checked'=>1),
148  's.zip'=>array('label'=>$langs->trans("Zip"), 'checked'=>1),
149  'state.nom'=>array('label'=>$langs->trans("StateShort"), 'checked'=>0),
150  'country.code_iso'=>array('label'=>$langs->trans("Country"), 'checked'=>0),
151  'typent.code'=>array('label'=>$langs->trans("ThirdPartyType"), 'checked'=>$checkedtypetiers),
152  'sp.date_valid'=>array('label'=>$langs->trans("Date"), 'checked'=>1),
153  'sp.date_livraison'=>array('label'=>$langs->trans("DateEnd"), 'checked'=>1),
154  'sp.total_ht'=>array('label'=>$langs->trans("AmountHT"), 'checked'=>1),
155  'sp.total_vat'=>array('label'=>$langs->trans("AmountVAT"), 'checked'=>0),
156  'sp.total_ttc'=>array('label'=>$langs->trans("AmountTTC"), 'checked'=>0),
157  'sp.multicurrency_code'=>array('label'=>'Currency', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)),
158  'sp.multicurrency_tx'=>array('label'=>'CurrencyRate', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)),
159  'sp.multicurrency_total_ht'=>array('label'=>'MulticurrencyAmountHT', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)),
160  'sp.multicurrency_total_vat'=>array('label'=>'MulticurrencyAmountVAT', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)),
161  'sp.multicurrency_total_ttc'=>array('label'=>'MulticurrencyAmountTTC', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)),
162  'u.login'=>array('label'=>$langs->trans("Author"), 'checked'=>1, 'position'=>10),
163  'sp.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500),
164  'sp.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500),
165  'sp.fk_statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000),
166 );
167 // Extra fields
168 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
169 
170 $object->fields = dol_sort_array($object->fields, 'position');
171 $arrayfields = dol_sort_array($arrayfields, 'position');
172 
173 
174 
175 /*
176  * Actions
177  */
178 
179 if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; }
180 if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; }
181 
182 $parameters = array('socid'=>$socid);
183 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
184 if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
185 
186 include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
187 
188 // Do we click on purge search criteria ?
189 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
190 {
191  $search_categ = '';
192  $search_user = '';
193  $search_sale = '';
194  $search_ref = '';
195  $search_societe = '';
196  $search_montant_ht = '';
197  $search_montant_vat = '';
198  $search_montant_ttc = '';
199  $search_multicurrency_code = '';
200  $search_multicurrency_tx = '';
201  $search_multicurrency_montant_ht = '';
202  $search_multicurrency_montant_vat = '';
203  $search_multicurrency_montant_ttc = '';
204  $search_login = '';
205  $search_product_category = '';
206  $search_town = '';
207  $search_zip = "";
208  $search_state = "";
209  $search_type = '';
210  $search_country = '';
211  $search_type_thirdparty = '';
212  $yearvalid = '';
213  $monthvalid = '';
214  $dayvalid = '';
215  $year = '';
216  $month = '';
217  $day = '';
218  $search_status = '';
219  $object_statut = '';
220 }
221 
222 if (empty($reshook))
223 {
224  $objectclass = 'SupplierProposal';
225  $objectlabel = 'SupplierProposals';
226  $permissiontoread = $user->rights->supplier_proposal->lire;
227  $permissiontodelete = $user->rights->supplier_proposal->supprimer;
228  $uploaddir = $conf->supplier_proposal->dir_output;
229  include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
230 }
231 
232 
233 
234 /*
235  * View
236  */
237 
238 
239 $now = dol_now();
240 
241 $form = new Form($db);
242 $formother = new FormOther($db);
243 $formfile = new FormFile($db);
244 $formpropal = new FormPropal($db);
245 $companystatic = new Societe($db);
246 $formcompany = new FormCompany($db);
247 
248 $help_url = 'EN:Ask_Price_Supplier|FR:Demande_de_prix_fournisseur';
249 //llxHeader('',$langs->trans('CommRequest'),$help_url);
250 
251 $sql = 'SELECT';
252 if ($sall || $search_product_category > 0 || $search_user > 0) $sql = 'SELECT DISTINCT';
253 $sql .= ' s.rowid as socid, s.nom as name, s.town, s.zip, s.fk_pays, s.client, s.code_client,';
254 $sql .= " typent.code as typent_code,";
255 $sql .= " state.code_departement as state_code, state.nom as state_name,";
256 $sql .= ' sp.rowid, sp.note_private, sp.total_ht, sp.tva as total_vat, sp.total as 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,';
257 $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,';
258 $sql .= ' sp.datec as date_creation, sp.tms as date_update,';
259 $sql .= " p.rowid as project_id, p.ref as project_ref,";
260 if (!$user->rights->societe->client->voir && !$socid) $sql .= " sc.fk_soc, sc.fk_user,";
261 $sql .= " u.firstname, u.lastname, u.photo, u.login";
262 // Add fields from extrafields
263 if (!empty($extrafields->attributes[$object->table_element]['label'])) {
264  foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : '');
265 }
266 // Add fields from hooks
267 $parameters = array();
268 $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook
269 $sql .= $hookmanager->resPrint;
270 $sql .= ' FROM '.MAIN_DB_PREFIX.'societe as s';
271 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays)";
272 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typent)";
273 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)";
274 $sql .= ', '.MAIN_DB_PREFIX.'supplier_proposal as sp';
275 if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (sp.rowid = ef.fk_object)";
276 if ($sall || $search_product_category > 0) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'supplier_proposaldet as pd ON sp.rowid=pd.fk_supplier_proposal';
277 if ($search_product_category > 0) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product=pd.fk_product';
278 $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'user as u ON sp.fk_user_author = u.rowid';
279 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = sp.fk_projet";
280 // We'll need this table joined to the select in order to filter by sale
281 if ($search_sale > 0 || (!$user->rights->societe->client->voir && !$socid)) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
282 if ($search_user > 0)
283 {
284  $sql .= ", ".MAIN_DB_PREFIX."element_contact as c";
285  $sql .= ", ".MAIN_DB_PREFIX."c_type_contact as tc";
286 }
287 $sql .= ' WHERE sp.fk_soc = s.rowid';
288 $sql .= ' AND sp.entity IN ('.getEntity('supplier_proposal').')';
289 if (!$user->rights->societe->client->voir && !$socid) //restriction
290 {
291  $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
292 }
293 if ($search_town) $sql .= natural_search('s.town', $search_town);
294 if ($search_zip) $sql .= natural_search("s.zip", $search_zip);
295 if ($search_state) $sql .= natural_search("state.nom", $search_state);
296 if ($search_country) $sql .= " AND s.fk_pays IN (".$search_country.')';
297 if ($search_type_thirdparty) $sql .= " AND s.fk_typent IN (".$search_type_thirdparty.')';
298 if ($search_ref) $sql .= natural_search('sp.ref', $search_ref);
299 if ($search_societe) $sql .= natural_search('s.nom', $search_societe);
300 if ($search_login) $sql .= natural_search('u.login', $search_login);
301 if ($search_montant_ht) $sql .= natural_search('sp.total_ht=', $search_montant_ht, 1);
302 if ($search_montant_vat != '') $sql .= natural_search("sp.tva", $search_montant_vat, 1);
303 if ($search_montant_ttc != '') $sql .= natural_search("sp.total", $search_montant_ttc, 1);
304 if ($search_multicurrency_code != '') $sql .= ' AND sp.multicurrency_code = "'.$db->escape($search_multicurrency_code).'"';
305 if ($search_multicurrency_tx != '') $sql .= natural_search('sp.multicurrency_tx', $search_multicurrency_tx, 1);
306 if ($search_multicurrency_montant_ht != '') $sql .= natural_search('sp.multicurrency_total_ht', $search_multicurrency_montant_ht, 1);
307 if ($search_multicurrency_montant_vat != '') $sql .= natural_search('sp.multicurrency_total_tva', $search_multicurrency_montant_vat, 1);
308 if ($search_multicurrency_montant_ttc != '') $sql .= natural_search('sp.multicurrency_total_ttc', $search_multicurrency_montant_ttc, 1);
309 if ($sall) $sql .= natural_search(array_keys($fieldstosearchall), $sall);
310 if ($socid) $sql .= ' AND s.rowid = '.$socid;
311 if ($search_status >= 0 && $search_status != '') $sql .= ' AND sp.fk_statut IN ('.$db->sanitize($db->escape($search_status)).')';
312 $sql .= dolSqlDateFilter("sp.date_livraison", $day, $month, $year);
313 $sql .= dolSqlDateFilter("sp.date_valid", $dayvalid, $monthvalid, $yearvalid);
314 if ($search_sale > 0) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$search_sale;
315 if ($search_user > 0)
316 {
317  $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 = ".$search_user;
318 }
319 // Add where from extra fields
320 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
321 // Add where from hooks
322 $parameters = array();
323 $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook
324 $sql .= $hookmanager->resPrint;
325 
326 $sql .= $db->order($sortfield, $sortorder);
327 $sql .= ', sp.ref DESC';
328 
329 // Count total nb of records
330 $nbtotalofrecords = '';
331 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
332 {
333  $resql = $db->query($sql);
334  $nbtotalofrecords = $db->num_rows($resql);
335  if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0
336  {
337  $page = 0;
338  $offset = 0;
339  }
340 }
341 
342 $sql .= $db->plimit($limit + 1, $offset);
343 
344 $resql = $db->query($sql);
345 if ($resql)
346 {
347  $objectstatic = new SupplierProposal($db);
348  $userstatic = new User($db);
349 
350  if ($socid > 0)
351  {
352  $soc = new Societe($db);
353  $soc->fetch($socid);
354  $title = $langs->trans('ListOfSupplierProposals').' - '.$soc->name;
355  } else {
356  $title = $langs->trans('ListOfSupplierProposals');
357  }
358 
359  $num = $db->num_rows($resql);
360 
361  $arrayofselected = is_array($toselect) ? $toselect : array();
362 
363  if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $sall)
364  {
365  $obj = $db->fetch_object($resql);
366 
367  $id = $obj->rowid;
368 
369  header("Location: ".DOL_URL_ROOT.'/supplier_proposal/card.php?id='.$id);
370 
371  exit;
372  }
373 
374  llxHeader('', $langs->trans('CommRequest'), $help_url);
375 
376  $param = '';
377  if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
378  if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
379  if ($sall) $param .= '&sall='.urlencode($sall);
380  if ($month) $param .= '&month='.urlencode($month);
381  if ($year) $param .= '&year='.urlencode($year);
382  if ($search_ref) $param .= '&search_ref='.urlencode($search_ref);
383  if ($search_societe) $param .= '&search_societe='.urlencode($search_societe);
384  if ($search_user > 0) $param .= '&search_user='.urlencode($search_user);
385  if ($search_sale > 0) $param .= '&search_sale='.urlencode($search_sale);
386  if ($search_montant_ht) $param .= '&search_montant_ht='.urlencode($search_montant_ht);
387  if ($search_multicurrency_code != '') $param .= '&search_multicurrency_code='.urlencode($search_multicurrency_code);
388  if ($search_multicurrency_tx != '') $param .= '&search_multicurrency_tx='.urlencode($search_multicurrency_tx);
389  if ($search_multicurrency_montant_ht != '') $param .= '&search_multicurrency_montant_ht='.urlencode($search_multicurrency_montant_ht);
390  if ($search_multicurrency_montant_vat != '') $param .= '&search_multicurrency_montant_vat='.urlencode($search_multicurrency_montant_vat);
391  if ($search_multicurrency_montant_ttc != '') $param .= '&search_multicurrency_montant_ttc='.urlencode($search_multicurrency_montant_ttc);
392  if ($search_login) $param .= '&search_login='.urlencode($search_login);
393  if ($search_town) $param .= '&search_town='.urlencode($search_town);
394  if ($search_zip) $param .= '&search_zip='.urlencode($search_zip);
395  if ($socid > 0) $param .= '&socid='.urlencode($socid);
396  if ($search_status != '') $param .= '&search_status='.urlencode($search_status);
397  if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss);
398  // Add $param from extra fields
399  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
400 
401  // List of mass actions available
402  $arrayofmassactions = array(
403  'generate_doc'=>$langs->trans("ReGeneratePDF"),
404  'builddoc'=>$langs->trans("PDFMerge"),
405  //'presend'=>$langs->trans("SendByMail"),
406  );
407  if ($user->rights->supplier_proposal->supprimer) $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
408  if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array();
409  $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
410 
411  $url = DOL_URL_ROOT.'/supplier_proposal/card.php?action=create';
412  if (!empty($socid)) $url .= '&socid='.$socid;
413  $newcardbutton = dolGetButtonTitle($langs->trans('NewAskPrice'), '', 'fa fa-plus-circle', $url, '', $user->rights->supplier_proposal->creer);
414 
415  // Fields title search
416  print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
417  if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
418  print '<input type="hidden" name="token" value="'.newToken().'">';
419  print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
420  print '<input type="hidden" name="action" value="list">';
421  print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
422  print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
423 
424  print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'supplier_proposal', 0, $newcardbutton, '', $limit, 0, 0, 1);
425 
426  $topicmail = "SendSupplierProposalRef";
427  $modelmail = "supplier_proposal_send";
428  $objecttmp = new SupplierProposal($db);
429  $trackid = 'spro'.$object->id;
430  include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
431 
432  if ($sall)
433  {
434  foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val);
435  print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'</div>';
436  }
437 
438  $i = 0;
439 
440  $moreforfilter = '';
441 
442  // If the user can view prospects other than his'
443  if ($user->rights->societe->client->voir || $socid)
444  {
445  $langs->load("commercial");
446  $moreforfilter .= '<div class="divsearchfield">';
447  $moreforfilter .= $langs->trans('ThirdPartiesOfSaleRepresentative').': ';
448  $moreforfilter .= $formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, 1, 'maxwidth300');
449  $moreforfilter .= '</div>';
450  }
451  // If the user can view prospects other than his'
452  if ($user->rights->societe->client->voir || $socid)
453  {
454  $moreforfilter .= '<div class="divsearchfield">';
455  $moreforfilter .= $langs->trans('LinkedToSpecificUsers').': ';
456  $moreforfilter .= $form->select_dolusers($search_user, 'search_user', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth300');
457  $moreforfilter .= '</div>';
458  }
459  // If the user can view products
460  if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire && ($user->rights->produit->lire || $user->rights->service->lire))
461  {
462  include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
463  $moreforfilter .= '<div class="divsearchfield">';
464  $moreforfilter .= $langs->trans('IncludingProductWithTag').': ';
465  $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, null, 'parent', null, null, 1);
466  $moreforfilter .= $form->selectarray('search_product_category', $cate_arbo, $search_product_category, 1, 0, 0, '', 0, 0, 0, 0, 'maxwidth300', 1);
467  $moreforfilter .= '</div>';
468  }
469  $parameters = array();
470  $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook
471  if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint;
472  else $moreforfilter = $hookmanager->resPrint;
473 
474  if (!empty($moreforfilter))
475  {
476  print '<div class="liste_titre liste_titre_bydiv centpercent">';
477  print $moreforfilter;
478  print '</div>';
479  }
480 
481  $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
482  $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
483  if ($massactionbutton) $selectedfields .= $form->showCheckAddButtons('checkforselect', 1);
484 
485  print '<div class="div-table-responsive">';
486  print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
487 
488  print '<tr class="liste_titre_filter">';
489  if (!empty($arrayfields['sp.ref']['checked']))
490  {
491  print '<td class="liste_titre">';
492  print '<input class="flat" size="6" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
493  print '</td>';
494  }
495  if (!empty($arrayfields['s.nom']['checked']))
496  {
497  print '<td class="liste_titre left">';
498  print '<input class="flat" type="text" size="12" name="search_societe" value="'.dol_escape_htmltag($search_societe).'">';
499  print '</td>';
500  }
501  if (!empty($arrayfields['s.town']['checked'])) print '<td class="liste_titre"><input class="flat" type="text" size="6" name="search_town" value="'.$search_town.'"></td>';
502  if (!empty($arrayfields['s.zip']['checked'])) print '<td class="liste_titre"><input class="flat" type="text" size="4" name="search_zip" value="'.$search_zip.'"></td>';
503  // State
504  if (!empty($arrayfields['state.nom']['checked']))
505  {
506  print '<td class="liste_titre">';
507  print '<input class="flat" size="4" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).'">';
508  print '</td>';
509  }
510  // Country
511  if (!empty($arrayfields['country.code_iso']['checked']))
512  {
513  print '<td class="liste_titre center">';
514  print $form->select_country($search_country, 'search_country', '', 0, 'minwidth100imp maxwidth100');
515  print '</td>';
516  }
517  // Company type
518  if (!empty($arrayfields['typent.code']['checked']))
519  {
520  print '<td class="liste_titre maxwidthonsmartphone center">';
521  print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 0, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT));
522  print '</td>';
523  }
524  // Date
525  if (!empty($arrayfields['sp.date_valid']['checked']))
526  {
527  print '<td class="liste_titre center">';
528  //print $langs->trans('Month').': ';
529  print '<input class="flat width25 valignmiddle" type="text" maxlength="2" name="monthvalid" value="'.dol_escape_htmltag($monthvalid).'">';
530  //print '&nbsp;'.$langs->trans('Year').': ';
531  $syearvalid = $yearvalid;
532  $formother->select_year($syearvalid, 'yearvalid', 1, 20, 5);
533  print '</td>';
534  }
535  // Date
536  if (!empty($arrayfields['sp.date_livraison']['checked']))
537  {
538  print '<td class="liste_titre center">';
539  //print $langs->trans('Month').': ';
540  print '<input class="flat width25 valignmiddle" type="text" maxlength="2" name="month" value="'.dol_escape_htmltag($month).'">';
541  //print '&nbsp;'.$langs->trans('Year').': ';
542  $syear = $year;
543  $formother->select_year($syear, 'year', 1, 20, 5);
544  print '</td>';
545  }
546 
547  if (!empty($arrayfields['sp.total_ht']['checked']))
548  {
549  // Amount
550  print '<td class="liste_titre right">';
551  print '<input class="flat" type="text" size="5" name="search_montant_ht" value="'.dol_escape_htmltag($search_montant_ht).'">';
552  print '</td>';
553  }
554  if (!empty($arrayfields['sp.total_vat']['checked']))
555  {
556  // Amount
557  print '<td class="liste_titre right">';
558  print '<input class="flat" type="text" size="5" name="search_montant_vat" value="'.dol_escape_htmltag($search_montant_vat).'">';
559  print '</td>';
560  }
561  if (!empty($arrayfields['sp.total_ttc']['checked']))
562  {
563  // Amount
564  print '<td class="liste_titre right">';
565  print '<input class="flat" type="text" size="5" name="search_montant_ttc" value="'.dol_escape_htmltag($search_montant_ttc).'">';
566  print '</td>';
567  }
568  if (!empty($arrayfields['sp.multicurrency_code']['checked']))
569  {
570  // Currency
571  print '<td class="liste_titre">';
572  print $form->selectMultiCurrency($search_multicurrency_code, 'search_multicurrency_code', 1);
573  print '</td>';
574  }
575  if (!empty($arrayfields['sp.multicurrency_tx']['checked']))
576  {
577  // Currency rate
578  print '<td class="liste_titre">';
579  print '<input class="flat" type="text" size="4" name="search_multicurrency_tx" value="'.dol_escape_htmltag($search_multicurrency_tx).'">';
580  print '</td>';
581  }
582  if (!empty($arrayfields['sp.multicurrency_total_ht']['checked']))
583  {
584  // Amount
585  print '<td class="liste_titre right">';
586  print '<input class="flat" type="text" size="4" name="search_multicurrency_montant_ht" value="'.dol_escape_htmltag($search_multicurrency_montant_ht).'">';
587  print '</td>';
588  }
589  if (!empty($arrayfields['sp.multicurrency_total_vat']['checked']))
590  {
591  // Amount
592  print '<td class="liste_titre right">';
593  print '<input class="flat" type="text" size="4" name="search_multicurrency_montant_vat" value="'.dol_escape_htmltag($search_multicurrency_montant_vat).'">';
594  print '</td>';
595  }
596  if (!empty($arrayfields['sp.multicurrency_total_ttc']['checked']))
597  {
598  // Amount
599  print '<td class="liste_titre right">';
600  print '<input class="flat" type="text" size="4" name="search_multicurrency_montant_ttc" value="'.dol_escape_htmltag($search_multicurrency_montant_ttc).'">';
601  print '</td>';
602  }
603  if (!empty($arrayfields['u.login']['checked']))
604  {
605  // Author
606  print '<td class="liste_titre center">';
607  print '<input class="flat" size="4" type="text" name="search_login" value="'.dol_escape_htmltag($search_login).'">';
608  print '</td>';
609  }
610  // Extra fields
611  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
612  // Fields from hook
613  $parameters = array('arrayfields'=>$arrayfields);
614  $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
615  print $hookmanager->resPrint;
616  // Date creation
617  if (!empty($arrayfields['sp.datec']['checked']))
618  {
619  print '<td class="liste_titre">';
620  print '</td>';
621  }
622  // Date modification
623  if (!empty($arrayfields['sp.tms']['checked']))
624  {
625  print '<td class="liste_titre">';
626  print '</td>';
627  }
628  // Status
629  if (!empty($arrayfields['sp.fk_statut']['checked']))
630  {
631  print '<td class="liste_titre maxwidthonsmartphone right">';
632  $formpropal->selectProposalStatus($search_status, 1, 0, 1, 'supplier', 'search_status');
633  print '</td>';
634  }
635  // Action column
636  print '<td class="liste_titre middle">';
637  $searchpicto = $form->showFilterButtons();
638  print $searchpicto;
639  print '</td>';
640 
641  print "</tr>\n";
642 
643  // Fields title
644  print '<tr class="liste_titre">';
645  if (!empty($arrayfields['sp.ref']['checked'])) print_liste_field_titre($arrayfields['sp.ref']['label'], $_SERVER["PHP_SELF"], 'sp.ref', '', $param, '', $sortfield, $sortorder);
646  if (!empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], 's.nom', '', $param, '', $sortfield, $sortorder);
647  if (!empty($arrayfields['s.town']['checked'])) print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], 's.town', '', $param, '', $sortfield, $sortorder);
648  if (!empty($arrayfields['s.zip']['checked'])) print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], 's.zip', '', $param, '', $sortfield, $sortorder);
649  if (!empty($arrayfields['state.nom']['checked'])) print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder);
650  if (!empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, '', $sortfield, $sortorder, 'center ');
651  if (!empty($arrayfields['typent.code']['checked'])) print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, '', $sortfield, $sortorder, 'center ');
652  if (!empty($arrayfields['sp.date_valid']['checked'])) print_liste_field_titre($arrayfields['sp.date_valid']['label'], $_SERVER["PHP_SELF"], 'sp.date_valid', '', $param, '', $sortfield, $sortorder, 'center ');
653  if (!empty($arrayfields['sp.date_livraison']['checked'])) print_liste_field_titre($arrayfields['sp.date_livraison']['label'], $_SERVER["PHP_SELF"], 'sp.date_livraison', '', $param, '', $sortfield, $sortorder, 'center ');
654  if (!empty($arrayfields['sp.total_ht']['checked'])) print_liste_field_titre($arrayfields['sp.total_ht']['label'], $_SERVER["PHP_SELF"], 'sp.total_ht', '', $param, '', $sortfield, $sortorder, 'right ');
655  if (!empty($arrayfields['sp.total_vat']['checked'])) print_liste_field_titre($arrayfields['sp.total_vat']['label'], $_SERVER["PHP_SELF"], 'sp.total_vat', '', $param, '', $sortfield, $sortorder, 'right ');
656  if (!empty($arrayfields['sp.total_ttc']['checked'])) print_liste_field_titre($arrayfields['sp.total_ttc']['label'], $_SERVER["PHP_SELF"], 'sp.total_ttc', '', $param, '', $sortfield, $sortorder, 'right ');
657  if (!empty($arrayfields['sp.multicurrency_code']['checked'])) print_liste_field_titre($arrayfields['sp.multicurrency_code']['label'], $_SERVER['PHP_SELF'], 'sp.multicurrency_code', '', $param, '', $sortfield, $sortorder);
658  if (!empty($arrayfields['sp.multicurrency_tx']['checked'])) print_liste_field_titre($arrayfields['sp.multicurrency_tx']['label'], $_SERVER['PHP_SELF'], 'sp.multicurrency_tx', '', $param, '', $sortfield, $sortorder);
659  if (!empty($arrayfields['sp.multicurrency_total_ht']['checked'])) print_liste_field_titre($arrayfields['sp.multicurrency_total_ht']['label'], $_SERVER['PHP_SELF'], 'sp.multicurrency_total_ht', '', $param, 'class="right"', $sortfield, $sortorder);
660  if (!empty($arrayfields['sp.multicurrency_total_vat']['checked'])) print_liste_field_titre($arrayfields['sp.multicurrency_total_vat']['label'], $_SERVER['PHP_SELF'], 'sp.multicurrency_total_tva', '', $param, 'class="right"', $sortfield, $sortorder);
661  if (!empty($arrayfields['sp.multicurrency_total_ttc']['checked'])) print_liste_field_titre($arrayfields['sp.multicurrency_total_ttc']['label'], $_SERVER['PHP_SELF'], 'sp.multicurrency_total_ttc', '', $param, 'class="right"', $sortfield, $sortorder);
662  if (!empty($arrayfields['u.login']['checked'])) print_liste_field_titre($arrayfields['u.login']['label'], $_SERVER["PHP_SELF"], 'u.login', '', $param, '', $sortfield, $sortorder, 'center ');
663  // Extra fields
664  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
665  // Hook fields
666  $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
667  $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
668  print $hookmanager->resPrint;
669  if (!empty($arrayfields['sp.datec']['checked'])) print_liste_field_titre($arrayfields['sp.datec']['label'], $_SERVER["PHP_SELF"], "sp.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
670  if (!empty($arrayfields['sp.tms']['checked'])) print_liste_field_titre($arrayfields['sp.tms']['label'], $_SERVER["PHP_SELF"], "sp.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap');
671  if (!empty($arrayfields['sp.fk_statut']['checked'])) print_liste_field_titre($arrayfields['sp.fk_statut']['label'], $_SERVER["PHP_SELF"], "sp.fk_statut", "", $param, '', $sortfield, $sortorder, 'right ');
672  print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
673  print '</tr>'."\n";
674 
675  $now = dol_now();
676  $i = 0;
677  $total = 0;
678  $subtotal = 0;
679  $totalarray = array();
680  while ($i < min($num, $limit))
681  {
682  $obj = $db->fetch_object($resql);
683 
684  $objectstatic->id = $obj->rowid;
685  $objectstatic->ref = $obj->ref;
686  $objectstatic->note_public = $obj->note_public;
687  $objectstatic->note_private = $obj->note_private;
688  $objectstatic->status = $obj->status;
689 
690  // Company
691  $companystatic->id = $obj->socid;
692  $companystatic->name = $obj->name;
693  $companystatic->client = $obj->client;
694  $companystatic->code_client = $obj->code_client;
695 
696  print '<tr class="oddeven">';
697 
698  if (!empty($arrayfields['sp.ref']['checked']))
699  {
700  print '<td class="nowrap">';
701 
702  print '<table class="nobordernopadding"><tr class="nocellnopadd">';
703  // Picto + Ref
704  print '<td class="nobordernopadding nowrap">';
705  print $objectstatic->getNomUrl(1, '', '', 0, -1, 1);
706  print '</td>';
707  // Warning
708  $warnornote = '';
709  //if ($obj->fk_statut == 1 && $db->jdate($obj->date_valid) < ($now - $conf->supplier_proposal->warning_delay)) $warnornote .= img_warning($langs->trans("Late"));
710  if ($warnornote)
711  {
712  print '<td style="min-width: 20px" class="nobordernopadding nowrap">';
713  print $warnornote;
714  print '</td>';
715  }
716  // Other picto tool
717  print '<td width="16" class="right nobordernopadding hideonsmartphone">';
718  $filename = dol_sanitizeFileName($obj->ref);
719  $filedir = $conf->supplier_proposal->dir_output.'/'.dol_sanitizeFileName($obj->ref);
720  $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->rowid;
721  print $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir);
722  print '</td></tr></table>';
723 
724  print "</td>\n";
725  if (!$i) $totalarray['nbfield']++;
726  }
727 
728  // Thirdparty
729  if (!empty($arrayfields['s.nom']['checked']))
730  {
731  print '<td class="tdoverflowmax200">';
732  print $companystatic->getNomUrl(1, 'customer');
733  print '</td>';
734  if (!$i) $totalarray['nbfield']++;
735  }
736 
737  // Town
738  if (!empty($arrayfields['s.town']['checked']))
739  {
740  print '<td class="nocellnopadd">';
741  print $obj->town;
742  print '</td>';
743  if (!$i) $totalarray['nbfield']++;
744  }
745  // Zip
746  if (!empty($arrayfields['s.zip']['checked']))
747  {
748  print '<td class="nocellnopadd">';
749  print $obj->zip;
750  print '</td>';
751  if (!$i) $totalarray['nbfield']++;
752  }
753  // State
754  if (!empty($arrayfields['state.nom']['checked']))
755  {
756  print "<td>".$obj->state_name."</td>\n";
757  if (!$i) $totalarray['nbfield']++;
758  }
759  // Country
760  if (!empty($arrayfields['country.code_iso']['checked']))
761  {
762  print '<td class="center">';
763  $tmparray = getCountry($obj->fk_pays, 'all');
764  print $tmparray['label'];
765  print '</td>';
766  if (!$i) $totalarray['nbfield']++;
767  }
768  // Type ent
769  if (!empty($arrayfields['typent.code']['checked']))
770  {
771  print '<td class="center">';
772  if (count($typenArray) == 0) $typenArray = $formcompany->typent_array(1);
773  print $typenArray[$obj->typent_code];
774  print '</td>';
775  if (!$i) $totalarray['nbfield']++;
776  }
777 
778  // Date proposal
779  if (!empty($arrayfields['sp.date_valid']['checked']))
780  {
781  print '<td class="center">';
782  print dol_print_date($db->jdate($obj->date_valid), 'day');
783  print "</td>\n";
784  if (!$i) $totalarray['nbfield']++;
785  }
786 
787  // Date delivery
788  if (!empty($arrayfields['sp.date_livraison']['checked']))
789  {
790  print '<td class="center">';
791  print dol_print_date($db->jdate($obj->dp), 'day');
792  print "</td>\n";
793  if (!$i) $totalarray['nbfield']++;
794  }
795 
796  // Amount HT
797  if (!empty($arrayfields['sp.total_ht']['checked']))
798  {
799  print '<td class="right">'.price($obj->total_ht)."</td>\n";
800  if (!$i) $totalarray['nbfield']++;
801  if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'sp.total_ht';
802  $totalarray['val']['sp.total_ht'] += $obj->total_ht;
803  }
804  // Amount VAT
805  if (!empty($arrayfields['sp.total_vat']['checked']))
806  {
807  print '<td class="right">'.price($obj->total_vat)."</td>\n";
808  if (!$i) $totalarray['nbfield']++;
809  if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'sp.total_vat';
810  $totalarray['val']['sp.total_vat'] += $obj->total_vat;
811  }
812  // Amount TTC
813  if (!empty($arrayfields['sp.total_ttc']['checked']))
814  {
815  print '<td class="right">'.price($obj->total_ttc)."</td>\n";
816  if (!$i) $totalarray['nbfield']++;
817  if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'sp.total_ttc';
818  $totalarray['val']['sp.total_ttc'] += $obj->total_ttc;
819  }
820 
821  // Currency
822  if (!empty($arrayfields['sp.multicurrency_code']['checked']))
823  {
824  print '<td class="nowrap">'.$obj->multicurrency_code.' - '.$langs->trans('Currency'.$obj->multicurrency_code)."</td>\n";
825  if (!$i) $totalarray['nbfield']++;
826  }
827 
828  // Currency rate
829  if (!empty($arrayfields['sp.multicurrency_tx']['checked']))
830  {
831  print '<td class="nowrap">';
832  $form->form_multicurrency_rate($_SERVER['PHP_SELF'].'?id='.$obj->rowid, $obj->multicurrency_tx, 'none', $obj->multicurrency_code);
833  print "</td>\n";
834  if (!$i) $totalarray['nbfield']++;
835  }
836  // Amount HT
837  if (!empty($arrayfields['sp.multicurrency_total_ht']['checked']))
838  {
839  print '<td class="right nowrap">'.price($obj->multicurrency_total_ht)."</td>\n";
840  if (!$i) $totalarray['nbfield']++;
841  }
842  // Amount VAT
843  if (!empty($arrayfields['sp.multicurrency_total_vat']['checked']))
844  {
845  print '<td class="right nowrap">'.price($obj->multicurrency_total_vat)."</td>\n";
846  if (!$i) $totalarray['nbfield']++;
847  }
848  // Amount TTC
849  if (!empty($arrayfields['sp.multicurrency_total_ttc']['checked']))
850  {
851  print '<td class="right nowrap">'.price($obj->multicurrency_total_ttc)."</td>\n";
852  if (!$i) $totalarray['nbfield']++;
853  }
854 
855  $userstatic->id = $obj->fk_user_author;
856  $userstatic->login = $obj->login;
857 
858  // Author
859  if (!empty($arrayfields['u.login']['checked']))
860  {
861  print '<td class="center">';
862  if ($userstatic->id) print $userstatic->getLoginUrl(1);
863  else print '&nbsp;';
864  print "</td>\n";
865  if (!$i) $totalarray['nbfield']++;
866  }
867 
868  // Extra fields
869  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
870  // Fields from hook
871  $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
872  $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook
873  print $hookmanager->resPrint;
874  // Date creation
875  if (!empty($arrayfields['sp.datec']['checked']))
876  {
877  print '<td class="center nowrap">';
878  print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser');
879  print '</td>';
880  if (!$i) $totalarray['nbfield']++;
881  }
882  // Date modification
883  if (!empty($arrayfields['sp.tms']['checked']))
884  {
885  print '<td class="center nowrap">';
886  print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser');
887  print '</td>';
888  if (!$i) $totalarray['nbfield']++;
889  }
890  // Status
891  if (!empty($arrayfields['sp.fk_statut']['checked']))
892  {
893  print '<td class="right">'.$objectstatic->getLibStatut(5)."</td>\n";
894  if (!$i) $totalarray['nbfield']++;
895  }
896 
897  // Action column
898  print '<td class="nowrap center">';
899  if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
900  {
901  $selected = 0;
902  if (in_array($obj->rowid, $arrayofselected)) $selected = 1;
903  print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
904  }
905  print '</td>';
906  if (!$i) $totalarray['nbfield']++;
907 
908  print "</tr>\n";
909 
910  $total += $obj->total_ht;
911  $subtotal += $obj->total_ht;
912 
913  $i++;
914  }
915 
916  // Show total line
917  include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
918 
919  $db->free($resql);
920 
921  $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql);
922  $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook
923  print $hookmanager->resPrint;
924 
925  print '</table>'."\n";
926  print '</div>'."\n";
927 
928  print '</form>'."\n";
929 
930  $hidegeneratedfilelistifempty = 1;
931  if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0;
932 
933  // Show list of available documents
934  $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
935  $urlsource .= str_replace('&amp;', '&', $param);
936 
937  $filedir = $diroutputmassaction;
938 
939  $genallowed = $user->rights->supplier_proposal->lire;
940  $delallowed = $user->rights->supplier_proposal->creer;
941 
942  print $formfile->showdocuments('massfilesarea_supplier_proposal', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
943 } else {
944  dol_print_error($db);
945 }
946 
947 // End of page
948 llxFooter();
949 $db->close();
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dolGetButtonTitle($label, $helpText= '', $iconClass= 'fa fa-file', $url= '', $id= '', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
dol_now($mode= 'auto')
Return date for now.
Class to manage Dolibarr users.
Definition: user.class.php:44
Class to manage generation of HTML components for proposal management.
llxHeader()
Empty header.
Definition: wrapper.php:45
Class to build HTML component for third parties management Only common components are here...
Class to manage standard extra fields.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
print_barre_liste($titre, $page, $file, $options= '', $sortfield= '', $sortorder= '', $morehtmlcenter= '', $num=-1, $totalnboflines= '', $picto= 'generic', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limit=-1, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow= '')
Print a title with navigation controls for pagination.
Class to manage generation of HTML components Only common components must be here.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname.
Class to manage third parties objects (customers, suppliers, prospects...)
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
Classe permettant la generation de composants html autre Only common components are here...
restrictedArea($user, $features, $objectid=0, $tableandshare= '', $feature2= '', $dbt_keyfield= 'fk_soc', $dbt_select= 'rowid', $isdraft=0)
Check permissions of a user to show a page and an object.
natural_search($fields, $value, $mode=0, $nofirstand=0)
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
dol_sanitizeFileName($str, $newstr= '_', $unaccent=1)
Clean a string to use it as a file name.
dolSqlDateFilter($datefield, $day_date, $month_date, $year_date, $excludefirstand=0)
Generate a SQL string to make a filter into a range (for second of date until last second of date) ...
Definition: date.lib.php:281
Class to offer components to list and upload files.
print $_SERVER["PHP_SELF"]
Edit parameters.
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
Draft customers invoices.
Definition: index.php:89
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
Class to manage price ask supplier.
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
Definition: index.php:1232
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
llxFooter()
Empty footer.
Definition: wrapper.php:59
if(!defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN'
Draft customers invoices.
getCountry($searchkey, $withcode= '', $dbtouse=0, $outputlangs= '', $entconv=1, $searchlabel= '')
Return country label, code or id from an id, code or label.