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