dolibarr 25.0.0-alpha
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-2023 Charlene Benke <charlene@patas-monkey.com>
14 * Copyright (C) 2021-2026 Alexandre Spangaro <alexandre@inovea-conseil.com>
15 * Copyright (C) 2024-2026 MDW <mdeweerd@users.noreply.github.com>
16 * Copyright (C) 2024 Benjamin Falière <benjamin.faliere@altairis.fr>
17 * Copyright (C) 2024-2026 Frédéric France <frederic.france@free.fr>
18 *
19 * This program is free software; you can redistribute it and/or modify
20 * it under the terms of the GNU General Public License as published by
21 * the Free Software Foundation; either version 3 of the License, or
22 * (at your option) any later version.
23 *
24 * This program is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 * GNU General Public License for more details.
28 *
29 * You should have received a copy of the GNU General Public License
30 * along with this program. If not, see <https://www.gnu.org/licenses/>.
31 */
32
39// Load Dolibarr environment
40require '../main.inc.php';
41require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
42require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
43require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
44require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
45require_once DOL_DOCUMENT_ROOT.'/core/class/html.formpropal.class.php';
46require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
47require_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class.php';
48require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
49
58// Load translation files required by the page
59$langs->loadLangs(array('companies', 'propal', 'supplier_proposal', 'compta', 'bills', 'orders', 'products', 'projects'));
60
61$socid = GETPOSTINT('socid');
62
63$action = GETPOST('action', 'aZ09');
64$massaction = GETPOST('massaction', 'alpha');
65$show_files = GETPOSTINT('show_files');
66$confirm = GETPOST('confirm', 'alpha');
67$toselect = GETPOST('toselect', 'array:int');
68$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'supplierproposallist';
69$optioncss = GETPOST('optioncss', 'alpha');
70$mode = GETPOST('mode', 'alpha');
71
72$search_user = GETPOST('search_user', 'intcomma');
73$search_sale = GETPOST('search_sale', 'intcomma');
74$search_ref = GETPOST('sf_ref') ? GETPOST('sf_ref', 'alpha') : GETPOST('search_ref', 'alpha');
75$search_company = GETPOST('search_company', 'alpha');
76$search_company_alias = GETPOST('search_company_alias', 'alpha');
77$search_login = GETPOST('search_login', 'alpha');
78$search_town = GETPOST('search_town', 'alpha');
79$search_zip = GETPOST('search_zip', 'alpha');
80$search_state = GETPOST("search_state");
81$search_country = GETPOST("search_country", 'aZ09');
82$search_date_startday = GETPOSTINT('search_date_startday');
83$search_date_startmonth = GETPOSTINT('search_date_startmonth');
84$search_date_startyear = GETPOSTINT('search_date_startyear');
85$search_date_endday = GETPOSTINT('search_date_endday');
86$search_date_endmonth = GETPOSTINT('search_date_endmonth');
87$search_date_endyear = GETPOSTINT('search_date_endyear');
88$search_date_start = dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear); // Use tzserver
89$search_date_end = dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear);
90$search_date_valid_startday = GETPOSTINT('search_date_valid_startday');
91$search_date_valid_startmonth = GETPOSTINT('search_date_valid_startmonth');
92$search_date_valid_startyear = GETPOSTINT('search_date_valid_startyear');
93$search_date_valid_endday = GETPOSTINT('search_date_valid_endday');
94$search_date_valid_endmonth = GETPOSTINT('search_date_valid_endmonth');
95$search_date_valid_endyear = GETPOSTINT('search_date_valid_endyear');
96$search_date_valid_start = dol_mktime(0, 0, 0, $search_date_valid_startmonth, $search_date_valid_startday, $search_date_valid_startyear); // Use tzserver
97$search_date_valid_end = dol_mktime(23, 59, 59, $search_date_valid_endmonth, $search_date_valid_endday, $search_date_valid_endyear);
98$search_type_thirdparty = GETPOST("search_type_thirdparty", 'intcomma');
99$search_montant_ht = GETPOST('search_montant_ht', 'alpha');
100$search_montant_vat = GETPOST('search_montant_vat', 'alpha');
101$search_montant_ttc = GETPOST('search_montant_ttc', 'alpha');
102$search_multicurrency_code = GETPOST('search_multicurrency_code', 'alpha');
103$search_multicurrency_tx = GETPOST('search_multicurrency_tx', 'alpha');
104$search_multicurrency_montant_ht = GETPOST('search_multicurrency_montant_ht', 'alpha');
105$search_multicurrency_montant_vat = GETPOST('search_multicurrency_montant_vat', 'alpha');
106$search_multicurrency_montant_ttc = GETPOST('search_multicurrency_montant_ttc', 'alpha');
107$search_project_ref = GETPOST('search_project_ref', 'alpha');
108$search_status = GETPOST('search_status', 'intcomma');
109$search_note_private = GETPOST('search_note_private', 'alpha');
110$search_note_public = GETPOST('search_note_public', 'alpha');
111$search_product_category = GETPOST('search_product_category', 'int');
112$searchCategorySupplierPropalList = GETPOST('search_category_supplier_proposal_list', 'array:int');
113$searchCategorySupplierPropalOperator = 0;
114if (GETPOSTISSET('formfilteraction')) {
115 $searchCategorySupplierPropalOperator = GETPOSTINT('search_category_supplier_proposal_operator');
116} elseif (getDolGlobalString('MAIN_SEARCH_CAT_OR_BY_DEFAULT')) {
117 $searchCategorySupplierPropalOperator = getDolGlobalString('MAIN_SEARCH_CAT_OR_BY_DEFAULT');
118}
119$search_all = trim(GETPOST('search_all', 'alphanohtml'));
120
121$object_statut = GETPOST('supplier_proposal_statut', 'intcomma');
122$search_btn = GETPOST('button_search', 'alpha');
123$search_remove_btn = GETPOST('button_removefilter', 'alpha');
124
125$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
126$sortfield = GETPOST('sortfield', 'aZ09comma');
127$sortorder = GETPOST('sortorder', 'aZ09comma');
128$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT('page');
129if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
130 // If $page is not defined, or '' or -1 or if we click on clear filters
131 $page = 0;
132}
133$offset = $limit * $page;
134$pageprev = $page - 1;
135$pagenext = $page + 1;
136if (!$sortfield) {
137 $sortfield = 'sp.ref';
138}
139if (!$sortorder) {
140 $sortorder = 'DESC';
141}
142
143if ($object_statut != '') {
144 $search_status = $object_statut;
145}
146
147// Number of line to choose predefined product/service from
148$NBLINES = 4;
149
150// Security check
151$module = 'supplier_proposal';
152$dbtable = '';
153$objectid = '';
154if (!empty($user->socid)) {
155 $socid = $user->socid;
156}
157if (!empty($socid)) {
158 $objectid = $socid;
159 $module = 'societe';
160 $dbtable = '&societe';
161}
162
163$diroutputmassaction = $conf->supplier_proposal->dir_output.'/temp/massgeneration/'.$user->id;
164
165// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
167$hookmanager->initHooks(array('supplier_proposallist'));
168$extrafields = new ExtraFields($db);
169
170// fetch optionals attributes and labels
171$extrafields->fetch_name_optionals_label($object->table_element);
172
173$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
174
175
176// List of fields to search into when doing a "search in all"
177$fieldstosearchall = array();
178foreach ($object->fields as $key => $val) {
179 if (!empty($val['searchall'])) {
180 $fieldstosearchall['sp.'.$key] = $val['label'];
181 }
182}
183$fieldstosearchall['pd.description'] = 'Description';
184$fieldstosearchall['s.nom'] = "ThirdParty";
185$fieldstosearchall['s.name_alias'] = "AliasNameShort";
186$fieldstosearchall['s.zip'] = "Zip";
187$fieldstosearchall['s.town'] = "Town";
188if (empty($user->socid)) {
189 $fieldstosearchall["p.note_private"] = "NotePrivate";
190}
191
192$checkedtypetiers = '0';
193$arrayfields = array(
194 'sp.ref' => array('label' => $langs->trans("Ref"), 'checked' => '1'),
195 's.nom' => array('label' => $langs->trans("Supplier"), 'checked' => '1'),
196 's.name_alias' => array('label' => "AliasNameShort", 'checked' => '0'),
197 's.town' => array('label' => $langs->trans("Town"), 'checked' => '1'),
198 's.zip' => array('label' => $langs->trans("Zip"), 'checked' => '1'),
199 'state.nom' => array('label' => $langs->trans("StateShort"), 'checked' => '0'),
200 'country.code_iso' => array('label' => $langs->trans("Country"), 'checked' => '0'),
201 'typent.code' => array('label' => $langs->trans("ThirdPartyType"), 'checked' => $checkedtypetiers),
202 'sp.date_valid' => array('label' => $langs->trans("DateValidation"), 'checked' => '1'),
203 'sp.date_livraison' => array('label' => $langs->trans("DateEnd"), 'checked' => '1'),
204 'sp.total_ht' => array('label' => $langs->trans("AmountHT"), 'checked' => '1'),
205 'sp.total_tva' => array('label' => $langs->trans("AmountVAT"), 'checked' => '0'),
206 'sp.total_ttc' => array('label' => $langs->trans("AmountTTC"), 'checked' => '0'),
207 'sp.multicurrency_code' => array('label' => 'Currency', 'checked' => '0', 'enabled' => (!isModEnabled("multicurrency") ? '0' : '1')),
208 'sp.multicurrency_tx' => array('label' => 'CurrencyRate', 'checked' => '0', 'enabled' => (!isModEnabled("multicurrency") ? '0' : '1')),
209 'sp.multicurrency_total_ht' => array('label' => 'MulticurrencyAmountHT', 'checked' => '0', 'enabled' => (!isModEnabled("multicurrency") ? '0' : '1')),
210 'sp.multicurrency_total_vat' => array('label' => 'MulticurrencyAmountVAT', 'checked' => '0', 'enabled' => (!isModEnabled("multicurrency") ? '0' : '1')),
211 'sp.multicurrency_total_ttc' => array('label' => 'MulticurrencyAmountTTC', 'checked' => '0', 'enabled' => (!isModEnabled("multicurrency") ? '0' : '1')),
212 'sp.fk_projet' => array('label' => $langs->trans("RefProject"), 'checked' => '1', 'enabled' => (!isModEnabled("project") ? '0' : '1')),
213 'u.login' => array('label' => $langs->trans("Author"), 'checked' => '1', 'position' => 10),
214 'sp.datec' => array('label' => $langs->trans("DateCreation"), 'checked' => '0', 'position' => 500),
215 'sp.tms' => array('label' => $langs->trans("DateModificationShort"), 'checked' => '0', 'position' => 500),
216 'sp.note_public' => array('label' => 'NotePublic', 'checked' => '0', 'position' => 520, 'enabled' => (getDolGlobalInt('MAIN_LIST_HIDE_PUBLIC_NOTES') ? '0' : '1')),
217 'sp.note_private' => array('label' => 'NotePrivate', 'checked' => '0', 'position' => 521, 'enabled' => (getDolGlobalInt('MAIN_LIST_HIDE_PRIVATE_NOTES') ? '0' : '1')),
218 'sp.fk_statut' => array('label' => $langs->trans("Status"), 'checked' => '1', 'position' => 1000),
219);
220// Extra fields
221include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
222// Add hook to complete $arrayfields
223$parameters = array('arrayfields' => &$arrayfields);
224$reshook = $hookmanager->executeHooks('completeArrayFields', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
225
226$object->fields = dol_sort_array($object->fields, 'position');
227$arrayfields = dol_sort_array($arrayfields, 'position');
228
229// Check only if it's an internal user
230if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) {
231 $search_sale = $user->id;
232}
233
234$result = restrictedArea($user, $module, $objectid, $dbtable);
235
236$permissiontoread = $user->hasRight('supplier_proposal', 'lire');
237$permissiontodelete = $user->hasRight('supplier_proposal', 'supprimer');
238$permissiontoadd = $user->hasRight('supplier_proposal', 'creer');
239
240/*
241 * Actions
242 */
243
244if (GETPOST('cancel', 'alpha')) {
245 $action = 'list';
246 $massaction = '';
247}
248if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
249 $massaction = '';
250}
251
252$parameters = array('socid' => $socid, 'arrayfields' => &$arrayfields);
253$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
254if ($reshook < 0) {
255 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
256}
257
258if (empty($reshook)) {
259 // Selection of new fields
260 include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
261
262 // Purge search criteria
263 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
264 $search_categ = '';
265 $search_user = '';
266 $search_sale = '';
267 $search_ref = '';
268 $search_company = '';
269 $search_company_alias = '';
270 $search_montant_ht = '';
271 $search_montant_vat = '';
272 $search_montant_ttc = '';
273 $search_multicurrency_code = '';
274 $search_multicurrency_tx = '';
275 $search_multicurrency_montant_ht = '';
276 $search_multicurrency_montant_vat = '';
277 $search_multicurrency_montant_ttc = '';
278 $search_project_ref = '';
279 $search_login = '';
280 $search_product_category = '';
281 $searchCategorySupplierPropalList = array();
282 $search_town = '';
283 $search_zip = "";
284 $search_state = "";
285 $search_type = '';
286 $search_country = '';
287 $search_type_thirdparty = '';
288 $search_date_startday = '';
289 $search_date_startmonth = '';
290 $search_date_startyear = '';
291 $search_date_endday = '';
292 $search_date_endmonth = '';
293 $search_date_endyear = '';
294 $search_date_start = '';
295 $search_date_end = '';
296 $search_date_valid_startday = '';
297 $search_date_valid_startmonth = '';
298 $search_date_valid_startyear = '';
299 $search_date_valid_endday = '';
300 $search_date_valid_endmonth = '';
301 $search_date_valid_endyear = '';
302 $search_date_valid_start = '';
303 $search_date_valid_end = '';
304 $search_status = '';
305 $object_statut = '';
306 }
307
308 $objectclass = 'SupplierProposal';
309 $objectlabel = 'SupplierProposals';
310 $uploaddir = $conf->supplier_proposal->dir_output;
311 include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
312}
313
314
315/*
316 * View
317 */
318
319$form = new Form($db);
320$formother = new FormOther($db);
321$formfile = new FormFile($db);
322$formpropal = new FormPropal($db);
323$companystatic = new Societe($db);
324$formcompany = new FormCompany($db);
325
326$now = dol_now();
327
328if ($socid > 0) {
329 $soc = new Societe($db);
330 $soc->fetch($socid);
331 if (empty($search_company)) {
332 $search_company = $soc->name;
333 }
334}
335
336$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
337$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
338
339$title = $langs->trans('ListOfSupplierProposals');
340$help_url = 'EN:Ask_Price_Supplier|FR:Demande_de_prix_fournisseur';
341
342
343// Build and execute select
344// --------------------------------------------------------------------
345$sql = 'SELECT';
346if ($search_all || $search_user > 0) {
347 $sql = 'SELECT DISTINCT';
348}
349$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,';
350$sql .= " typent.code as typent_code,";
351$sql .= " state.code_departement as state_code, state.nom as state_name,";
352$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,';
353$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,';
354$sql .= ' sp.datec as date_creation, sp.tms as date_modification,';
355$sql .= " p.rowid as project_id, p.ref as project_ref, p.title as project_title,";
356$sql .= " u.firstname, u.lastname, u.photo, u.login, u.statut as ustatus, u.admin, u.employee, u.email as uemail";
357// Add fields from extrafields
358if (!empty($extrafields->attributes[$object->table_element]['label'])) {
359 foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
360 $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : '');
361 }
362}
363// Add fields from hooks
364$parameters = array();
365$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook
366$sql .= $hookmanager->resPrint;
367$sql .= ' FROM '.MAIN_DB_PREFIX.'societe as s';
368$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays)";
369$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typent)";
370$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)";
371$sql .= ', '.MAIN_DB_PREFIX.'supplier_proposal as sp';
372if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
373 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (sp.rowid = ef.fk_object)";
374}
375if ($search_all) {
376 $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'supplier_proposaldet as pd ON sp.rowid=pd.fk_supplier_proposal';
377}
378$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'user as u ON sp.fk_user_author = u.rowid';
379$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = sp.fk_projet";
380if ($search_user > 0) {
381 $sql .= ", ".MAIN_DB_PREFIX."element_contact as c";
382 $sql .= ", ".MAIN_DB_PREFIX."c_type_contact as tc";
383}
384$sql .= ' WHERE sp.fk_soc = s.rowid';
385$sql .= ' AND sp.entity IN ('.getEntity('supplier_proposal').')';
386if ($search_town) {
387 $sql .= natural_search('s.town', $search_town);
388}
389if ($search_zip) {
390 $sql .= natural_search("s.zip", $search_zip);
391}
392if ($search_state) {
393 $sql .= natural_search("state.nom", $search_state);
394}
395if ($search_country) {
396 $sql .= " AND s.fk_pays IN (".$db->sanitize($search_country).')';
397}
398if ($search_type_thirdparty != '' && $search_type_thirdparty > 0) {
399 $sql .= " AND s.fk_typent IN (".$db->sanitize($search_type_thirdparty).')';
400}
401if ($search_ref) {
402 $sql .= natural_search('sp.ref', $search_ref);
403}
404if (empty($arrayfields['s.name_alias']['checked']) && $search_company) {
405 $sql .= natural_search(array("s.nom", "s.name_alias"), $search_company);
406} else {
407 if ($search_company) {
408 $sql .= natural_search('s.nom', $search_company);
409 }
410 if ($search_company_alias) {
411 $sql .= natural_search('s.name_alias', $search_company_alias);
412 }
413}
414if ($search_login) {
415 $sql .= natural_search(array('u.lastname', 'u.firstname', 'u.login'), $search_login);
416}
417if ($search_montant_ht) {
418 $sql .= natural_search('sp.total_ht', $search_montant_ht, 1);
419}
420if ($search_montant_vat != '') {
421 $sql .= natural_search("sp.total_tva", $search_montant_vat, 1);
422}
423if ($search_montant_ttc != '') {
424 $sql .= natural_search("sp.total_ttc", $search_montant_ttc, 1);
425}
426if ($search_multicurrency_code != '') {
427 $sql .= " AND sp.multicurrency_code = '".$db->escape($search_multicurrency_code)."'";
428}
429if ($search_multicurrency_tx != '') {
430 $sql .= natural_search('sp.multicurrency_tx', $search_multicurrency_tx, 1);
431}
432if ($search_multicurrency_montant_ht != '') {
433 $sql .= natural_search('sp.multicurrency_total_ht', $search_multicurrency_montant_ht, 1);
434}
435if ($search_multicurrency_montant_vat != '') {
436 $sql .= natural_search('sp.multicurrency_total_tva', $search_multicurrency_montant_vat, 1);
437}
438if ($search_multicurrency_montant_ttc != '') {
439 $sql .= natural_search('sp.multicurrency_total_ttc', $search_multicurrency_montant_ttc, 1);
440}
441if ($search_project_ref != '') {
442 $sql .= natural_search("p.ref", $search_project_ref);
443}
444if ($search_all) {
445 $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
446}
447if ($socid > 0) {
448 $sql .= ' AND s.rowid = '.((int) $socid);
449}
450if ($search_status >= 0 && $search_status != '') {
451 $sql .= ' AND sp.fk_statut IN ('.$db->sanitize($db->escape($search_status)).')';
452}
453if ($search_date_start) {
454 $sql .= " AND sp.date_livraison >= '".$db->idate($search_date_start)."'";
455}
456if ($search_date_end) {
457 $sql .= " AND sp.date_livraison <= '".$db->idate($search_date_end)."'";
458}
459if ($search_date_valid_start) {
460 $sql .= " AND sp.date_valid >= '".$db->idate($search_date_valid_start)."'";
461}
462if ($search_note_public) {
463 $sql .= " AND p.note_public LIKE '%".$db->escape($db->escapeforlike($search_note_public))."%'";
464}
465if ($search_note_private) {
466 $sql .= " AND p.note_private LIKE '%".$db->escape($db->escapeforlike($search_note_private))."%'";
467}
468if ($search_date_valid_end) {
469 $sql .= " AND sp.date_valid <= '".$db->idate($search_date_valid_end)."'";
470}
471/*
472if ($search_sale > 0) {
473 $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $search_sale);
474}*/
475if ($search_user > 0) {
476 $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);
477}
478// Search on sale representative
479if ($search_sale && $search_sale != '-1') {
480 if ($search_sale == -2) {
481 $sql .= " AND ".getSalesRepresentativeSqlFilter('sp.fk_soc', 0, 1);
482 } elseif ($search_sale > 0) {
483 $sql .= " AND ".getSalesRepresentativeSqlFilter('sp.fk_soc', (int) $search_sale);
484 }
485}
486// Search for tag/category ($searchCategorySupplierInvoiceList is an array of ID)
487if (!empty($searchCategorySupplierPropalList)) {
488 $searchCategorySupplierPropalSqlList = array();
489 $listofcategoryid = '';
490 foreach ($searchCategorySupplierPropalList as $searchCategorySupplierPropal) {
491 if (intval($searchCategorySupplierPropal) == -2) {
492 $searchCategorySupplierPropalSqlList[] = "NOT EXISTS (SELECT ck.fk_supplier_proposal FROM ".MAIN_DB_PREFIX."categorie_supplier_proposal as ck WHERE sp.rowid = ck.fk_supplier_proposal)";
493 } elseif (intval($searchCategorySupplierPropal) > 0) {
494 if ($searchCategorySupplierPropalOperator == 0) {
495 $searchCategorySupplierPropalSqlList[] = " EXISTS (SELECT ck.fk_supplier_proposal FROM ".MAIN_DB_PREFIX."categorie_supplier_proposal as ck WHERE sp.rowid = ck.fk_supplier_proposal AND ck.fk_categorie = ".((int) $searchCategorySupplierPropal).")";
496 } else {
497 $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategorySupplierPropal);
498 }
499 }
500 }
501 if ($listofcategoryid) {
502 $searchCategorySupplierPropalSqlList[] = " EXISTS (SELECT ck.fk_supplier_proposal FROM ".MAIN_DB_PREFIX."categorie_supplier_proposal as ck WHERE sp.rowid = ck.fk_supplier_proposal AND ck.fk_categorie IN (".$db->sanitize($listofcategoryid)."))";
503 }
504 if ($searchCategorySupplierPropalOperator == 1) {
505 if (!empty($searchCategorySupplierPropalSqlList)) {
506 $sql .= " AND (".implode(' OR ', $searchCategorySupplierPropalSqlList).")";
507 }
508 } else {
509 if (!empty($searchCategorySupplierPropalSqlList)) {
510 $sql .= " AND (".implode(' AND ', $searchCategorySupplierPropalSqlList).")";
511 }
512 }
513}
514// Search for tag/category ($searchCategoryProductList is an array of ID)
515$searchCategoryProductOperator = GETPOSTINT('search_category_product_operator');
516$searchCategoryProductList = array($search_product_category);
517if (!empty($searchCategoryProductList)) {
518 $searchCategoryProductSqlList = array();
519 $listofcategoryid = '';
520 foreach ($searchCategoryProductList as $searchCategoryProduct) {
521 if (intval($searchCategoryProduct) == -2) {
522 $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)";
523 } elseif (intval($searchCategoryProduct) > 0) {
524 if ($searchCategoryProductOperator == 0) {
525 $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).")";
526 } else {
527 $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryProduct);
528 }
529 }
530 }
531 if ($listofcategoryid) {
532 $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)."))";
533 }
534 if ($searchCategoryProductOperator == 1) {
535 if (!empty($searchCategoryProductSqlList)) {
536 $sql .= " AND (".implode(' OR ', $searchCategoryProductSqlList).")";
537 }
538 } else {
539 if (!empty($searchCategoryProductSqlList)) {
540 $sql .= " AND (".implode(' AND ', $searchCategoryProductSqlList).")";
541 }
542 }
543}
544// Add where from extra fields
545include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
546// Add where from hooks
547$parameters = array();
548$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
549$sql .= $hookmanager->resPrint;
550
551$sql .= $db->order($sortfield, $sortorder);
552$sql .= ', sp.ref DESC';
553
554// Count total nb of records
555$nbtotalofrecords = '';
556if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
557 $resql = $db->query($sql);
558 $nbtotalofrecords = $db->num_rows($resql);
559 if (($page * $limit) > (int) $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
560 $page = 0;
561 $offset = 0;
562 }
563}
564
565$sql .= $db->plimit($limit + 1, $offset);
566
567$resql = $db->query($sql);
568if ($resql) {
569 $objectstatic = new SupplierProposal($db);
570 $userstatic = new User($db);
571
572 if ($socid > 0) {
573 $soc = new Societe($db);
574 $soc->fetch($socid);
575 $title = $langs->trans('SupplierProposals').' - '.$soc->name;
576 } else {
577 $title = $langs->trans('SupplierProposals');
578 }
579
580 $num = $db->num_rows($resql);
581
582 $arrayofselected = is_array($toselect) ? $toselect : array();
583
584 if ($num == 1 && getDolGlobalString('MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all) {
585 $obj = $db->fetch_object($resql);
586
587 $id = $obj->rowid;
588
589 header("Location: ".DOL_URL_ROOT.'/supplier_proposal/card.php?id='.$id);
590 exit;
591 }
592
593 // Output page
594 // --------------------------------------------------------------------
595
596 llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'bodyforlist mod-supplierproposal page-list');
597
598 $param = '';
599 if (!empty($mode)) {
600 $param .= '&mode='.urlencode($mode);
601 }
602 if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
603 $param .= '&contextpage='.urlencode($contextpage);
604 }
605 if ($limit > 0 && $limit != $conf->liste_limit) {
606 $param .= '&limit='.((int) $limit);
607 }
608 if ($search_all) {
609 $param .= '&search_all='.urlencode($search_all);
610 }
611 if ($search_date_startday) {
612 $param .= '&search_date_startday='.urlencode((string) ($search_date_startday));
613 }
614 if ($search_date_startmonth) {
615 $param .= '&search_date_startmonth='.urlencode((string) ($search_date_startmonth));
616 }
617 if ($search_date_startyear) {
618 $param .= '&search_date_startyear='.urlencode((string) ($search_date_startyear));
619 }
620 if ($search_date_endday) {
621 $param .= '&search_date_endday='.urlencode((string) ($search_date_endday));
622 }
623 if ($search_date_endmonth) {
624 $param .= '&search_date_endmonth='.urlencode((string) ($search_date_endmonth));
625 }
626 if ($search_date_endyear) {
627 $param .= '&search_date_endyear='.urlencode((string) ($search_date_endyear));
628 }
629 if ($search_date_valid_startday) {
630 $param .= '&search_date_valid_startday='.urlencode((string) ($search_date_valid_startday));
631 }
632 if ($search_date_valid_startmonth) {
633 $param .= '&search_date_valid_startmonth='.urlencode((string) ($search_date_valid_startmonth));
634 }
635 if ($search_date_valid_startyear) {
636 $param .= '&search_date_valid_startyear='.urlencode((string) ($search_date_valid_startyear));
637 }
638 if ($search_date_valid_endday) {
639 $param .= '&search_date_valid_endday='.urlencode((string) ($search_date_valid_endday));
640 }
641 if ($search_date_valid_endmonth) {
642 $param .= '&search_date_valid_endmonth='.urlencode((string) ($search_date_valid_endmonth));
643 }
644 if ($search_date_valid_endyear) {
645 $param .= '&search_date_valid_endyear='.urlencode((string) ($search_date_valid_endyear));
646 }
647 if ($search_ref) {
648 $param .= '&search_ref='.urlencode($search_ref);
649 }
650 if ($search_company) {
651 $param .= '&search_company='.urlencode($search_company);
652 }
653 if ($search_company_alias) {
654 $param .= '&search_company_alias='.urlencode($search_company_alias);
655 }
656 if ($search_user > 0) {
657 $param .= '&search_user='.urlencode((string) ($search_user));
658 }
659 if ($search_sale > 0) {
660 $param .= '&search_sale='.urlencode($search_sale);
661 }
662 if ($search_montant_ht) {
663 $param .= '&search_montant_ht='.urlencode($search_montant_ht);
664 }
665 if ($search_multicurrency_code != '') {
666 $param .= '&search_multicurrency_code='.urlencode($search_multicurrency_code);
667 }
668 if ($search_multicurrency_tx != '') {
669 $param .= '&search_multicurrency_tx='.urlencode($search_multicurrency_tx);
670 }
671 if ($search_multicurrency_montant_ht != '') {
672 $param .= '&search_multicurrency_montant_ht='.urlencode($search_multicurrency_montant_ht);
673 }
674 if ($search_multicurrency_montant_vat != '') {
675 $param .= '&search_multicurrency_montant_vat='.urlencode($search_multicurrency_montant_vat);
676 }
677 if ($search_multicurrency_montant_ttc != '') {
678 $param .= '&search_multicurrency_montant_ttc='.urlencode($search_multicurrency_montant_ttc);
679 }
680 if ($search_login) {
681 $param .= '&search_login='.urlencode($search_login);
682 }
683 if ($searchCategorySupplierPropalOperator == 1) {
684 $param .= "&search_category_supplier_propal_operator=".urlencode((string) ($searchCategorySupplierPropalOperator));
685 }
686 foreach ($searchCategorySupplierPropalList as $searchCategorySupplierPropal) {
687 $param .= "&search_category_supplier_invoice_list[]=".urlencode($searchCategorySupplierPropal);
688 }
689 if ($search_town) {
690 $param .= '&search_town='.urlencode($search_town);
691 }
692 if ($search_zip) {
693 $param .= '&search_zip='.urlencode($search_zip);
694 }
695 if ($socid > 0) {
696 $param .= '&socid='.urlencode((string) ($socid));
697 }
698 if ($search_status != '') {
699 $param .= '&search_status='.urlencode($search_status);
700 }
701 if ($search_project_ref >= 0) {
702 $param .= "&search_project_ref=".urlencode($search_project_ref);
703 }
704 if ($optioncss != '') {
705 $param .= '&optioncss='.urlencode($optioncss);
706 }
707 if ($search_type_thirdparty != '' && $search_type_thirdparty > 0) {
708 $param .= '&search_type_thirdparty='.urlencode((string) ($search_type_thirdparty));
709 }
710 // Add $param from extra fields
711 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
712
713 // List of mass actions available
714 $arrayofmassactions = array(
715 'generate_doc' => img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("ReGeneratePDF"),
716 'builddoc' => img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
717 //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
718 );
719 if (isModEnabled('category') && $user->hasRight('supplier_proposal', 'lire')) {
720 $arrayofmassactions['preaffecttag'] = img_picto('', 'category', 'class="pictofixedwidth"').$langs->trans("AffectTag");
721 }
722 if ($user->hasRight('supplier_proposal', 'supprimer')) {
723 $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
724 }
725 if (in_array($massaction, array('presend', 'predelete'))) {
726 $arrayofmassactions = array();
727 }
728 $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
729
730 $url = DOL_URL_ROOT.'/supplier_proposal/card.php?action=create';
731 if (!empty($socid)) {
732 $url .= '&socid='.$socid;
733 }
734 $newcardbutton = '';
735 $newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss' => 'reposition'));
736 $newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss' => 'reposition'));
737 $newcardbutton .= dolGetButtonTitle($langs->trans('Statistics'), '', 'fa fa-chart-bar imgforviewmode', DOL_URL_ROOT.'/comm/propal/stats/index.php?mode=supplier'.preg_replace('/(&|\?)*(mode|groupby)=[^&]+/', '', $param), '', ($mode == 'statistics' ? 2 : 1), array('morecss' => 'reposition'));
738 $newcardbutton .= dolGetButtonTitleSeparator();
739 $newcardbutton .= dolGetButtonTitle($langs->trans('NewAskPrice'), '', 'fa fa-plus-circle', $url, '', $user->hasRight('supplier_proposal', 'creer'));
740
741 // Fields title search
742 print '<form method="POST" id="searchFormList" action="'.dolBuildUrl($_SERVER["PHP_SELF"]).'">';
743 if ($optioncss != '') {
744 print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
745 }
746 print '<input type="hidden" name="token" value="'.newToken().'">';
747 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
748 print '<input type="hidden" name="action" value="list">';
749 print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
750 print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
751 print '<input type="hidden" name="mode" value="'.$mode.'">';
752
753 print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'supplier_proposal', 0, $newcardbutton, '', $limit, 0, 0, 1);
754
755 $topicmail = "SendSupplierProposalRef";
756 $modelmail = "supplier_proposal_send";
757 $objecttmp = new SupplierProposal($db);
758 $trackid = 'spro'.$object->id;
759 include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
760
761 if ($search_all) {
762 foreach ($fieldstosearchall as $key => $val) {
763 $fieldstosearchall[$key] = $langs->trans($val);
764 }
765 print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).implode(', ', $fieldstosearchall).'</div>';
766 }
767
768 $i = 0;
769
770 $moreforfilter = '';
771 if (isModEnabled('category') && $user->hasRight('categorie', 'read')) {
772 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcategory.class.php';
773 $formcategory = new FormCategory($db);
774 $moreforfilter .= $formcategory->getFilterBox(Categorie::TYPE_SUPPLIER_PROPOSAL, $searchCategorySupplierPropalList, 'minwidth300', $searchCategorySupplierPropalOperator ? $searchCategorySupplierPropalOperator : 0);
775 }
776 // If the user can view prospects other than his'
777 if ($user->hasRight('user', 'user', 'lire')) {
778 $langs->load("commercial");
779 $moreforfilter .= '<div class="divsearchfield">';
780 $tmptitle = $langs->trans('ThirdPartiesOfSaleRepresentative');
781 $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, $tmptitle, 'maxwidth250 widthcentpercentminusx');
782 $moreforfilter .= '</div>';
783 }
784 // If the user can view prospects other than his'
785 if ($user->hasRight('user', 'user', 'lire')) {
786 $moreforfilter .= '<div class="divsearchfield">';
787 $tmptitle = $langs->trans('LinkedToSpecificUsers');
788 $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$form->select_dolusers($search_user, 'search_user', $tmptitle, null, 0, '', '', '0', 0, 0, '', 0, '', 'maxwidth250 widthcentpercentminusx');
789 $moreforfilter .= '</div>';
790 }
791 // If the user can view products
792 if (isModEnabled('category') && $user->hasRight('categorie', 'lire') && ($user->hasRight('produit', 'lire') || $user->hasRight('service', 'lire'))) {
793 include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
794 $moreforfilter .= '<div class="divsearchfield">';
795 $tmptitle = $langs->trans('IncludingProductWithTag');
796 $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, '', 'parent', 0, 0, 1);
797 $moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"').$form->selectarray('search_product_category', $cate_arbo, $search_product_category, $tmptitle, 0, 0, '', 0, 0, 0, '', 'maxwidth300 widthcentpercentminusx', 1);
798 $moreforfilter .= '</div>';
799 }
800 $parameters = array();
801 $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
802 if (empty($reshook)) {
803 $moreforfilter .= $hookmanager->resPrint;
804 } else {
805 $moreforfilter = $hookmanager->resPrint;
806 }
807
808 if (!empty($moreforfilter)) {
809 print '<div class="liste_titre liste_titre_bydiv centpercent">';
810 print $moreforfilter;
811 print '</div>';
812 }
813
814 $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
815 $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, $conf->main_checkbox_left_column); // This also change content of $arrayfields
816 $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
817
818 print '<div class="div-table-responsive">';
819 print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
820
821 // Fields title search
822 // --------------------------------------------------------------------
823 print '<tr class="liste_titre_filter">';
824 // Action column
825 if ($conf->main_checkbox_left_column) {
826 print '<td class="liste_titre maxwidthsearch">';
827 $searchpicto = $form->showFilterButtons('left');
828 print $searchpicto;
829 print '</td>';
830 }
831 if (!empty($arrayfields['sp.ref']['checked'])) {
832 print '<td class="liste_titre">';
833 print '<input class="flat" size="6" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
834 print '</td>';
835 }
836 // Project ref
837 if (!empty($arrayfields['sp.fk_projet']['checked'])) {
838 print '<td class="liste_titre">';
839 print '<input type="text" class="flat" name="search_project_ref" value="'.$search_project_ref.'">';
840 print '</td>';
841 }
842 if (!empty($arrayfields['s.nom']['checked'])) {
843 print '<td class="liste_titre left">';
844 print '<input class="flat" type="text" size="12" name="search_company" value="'.dol_escape_htmltag((string) $search_company).'">';
845 print '</td>';
846 }
847 if (!empty($arrayfields['s.name_alias']['checked'])) {
848 print '<td class="liste_titre left">';
849 print '<input class="flat" type="text" size="12" name="search_company_alias" value="'.dol_escape_htmltag($search_company_alias).'">';
850 print '</td>';
851 }
852 if (!empty($arrayfields['s.town']['checked'])) {
853 print '<td class="liste_titre"><input class="flat" type="text" size="6" name="search_town" value="'.$search_town.'"></td>';
854 }
855 if (!empty($arrayfields['s.zip']['checked'])) {
856 print '<td class="liste_titre"><input class="flat" type="text" size="4" name="search_zip" value="'.$search_zip.'"></td>';
857 }
858 // State
859 if (!empty($arrayfields['state.nom']['checked'])) {
860 print '<td class="liste_titre">';
861 print '<input class="flat" size="4" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).'">';
862 print '</td>';
863 }
864 // Country
865 if (!empty($arrayfields['country.code_iso']['checked'])) {
866 print '<td class="liste_titre center">';
867 print $form->select_country($search_country, 'search_country', '', 0, 'minwidth100imp maxwidth100');
868 print '</td>';
869 }
870 // Company type
871 if (!empty($arrayfields['typent.code']['checked'])) {
872 print '<td class="liste_titre maxwidthonsmartphone center">';
873 print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 1, 0, 0, '', 0, 0, 0, getDolGlobalString('SOCIETE_SORT_ON_TYPEENT', 'ASC'), '', 1);
874 print '</td>';
875 }
876 // Date
877 if (!empty($arrayfields['sp.date_valid']['checked'])) {
878 print '<td class="liste_titre center">';
879 print '<div class="nowrapfordate">';
880 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'));
881 print '</div>';
882 print '<div class="nowrapfordate">';
883 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'));
884 print '</div>';
885 print '</td>';
886 }
887 // Date
888 if (!empty($arrayfields['sp.date_livraison']['checked'])) {
889 print '<td class="liste_titre center">';
890 print '<div class="nowrapfordate">';
891 print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
892 print '</div>';
893 print '<div class="nowrapfordate">';
894 print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
895 print '</div>';
896 print '</td>';
897 }
898
899 if (!empty($arrayfields['sp.total_ht']['checked'])) {
900 // Amount
901 print '<td class="liste_titre right">';
902 print '<input class="flat" type="text" size="5" name="search_montant_ht" value="'.dol_escape_htmltag($search_montant_ht).'">';
903 print '</td>';
904 }
905 if (!empty($arrayfields['sp.total_tva']['checked'])) {
906 // Amount
907 print '<td class="liste_titre right">';
908 print '<input class="flat" type="text" size="5" name="search_montant_vat" value="'.dol_escape_htmltag($search_montant_vat).'">';
909 print '</td>';
910 }
911 if (!empty($arrayfields['sp.total_ttc']['checked'])) {
912 // Amount
913 print '<td class="liste_titre right">';
914 print '<input class="flat" type="text" size="5" name="search_montant_ttc" value="'.dol_escape_htmltag($search_montant_ttc).'">';
915 print '</td>';
916 }
917 if (!empty($arrayfields['sp.multicurrency_code']['checked'])) {
918 // Currency
919 print '<td class="liste_titre">';
920 print $form->selectMultiCurrency($search_multicurrency_code, 'search_multicurrency_code', 1);
921 print '</td>';
922 }
923 if (!empty($arrayfields['sp.multicurrency_tx']['checked'])) {
924 // Currency rate
925 print '<td class="liste_titre">';
926 print '<input class="flat" type="text" size="4" name="search_multicurrency_tx" value="'.dol_escape_htmltag($search_multicurrency_tx).'">';
927 print '</td>';
928 }
929 if (!empty($arrayfields['sp.multicurrency_total_ht']['checked'])) {
930 // Amount
931 print '<td class="liste_titre right">';
932 print '<input class="flat" type="text" size="4" name="search_multicurrency_montant_ht" value="'.dol_escape_htmltag($search_multicurrency_montant_ht).'">';
933 print '</td>';
934 }
935 if (!empty($arrayfields['sp.multicurrency_total_vat']['checked'])) {
936 // Amount
937 print '<td class="liste_titre right">';
938 print '<input class="flat" type="text" size="4" name="search_multicurrency_montant_vat" value="'.dol_escape_htmltag($search_multicurrency_montant_vat).'">';
939 print '</td>';
940 }
941 if (!empty($arrayfields['sp.multicurrency_total_ttc']['checked'])) {
942 // Amount
943 print '<td class="liste_titre right">';
944 print '<input class="flat" type="text" size="4" name="search_multicurrency_montant_ttc" value="'.dol_escape_htmltag($search_multicurrency_montant_ttc).'">';
945 print '</td>';
946 }
947 if (!empty($arrayfields['u.login']['checked'])) {
948 // Author
949 print '<td class="liste_titre center">';
950 print '<input class="flat" size="4" type="text" name="search_login" value="'.dol_escape_htmltag($search_login).'">';
951 print '</td>';
952 }
953 // Extra fields
954 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
955 // Fields from hook
956 $parameters = array('arrayfields' => $arrayfields);
957 $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
958 print $hookmanager->resPrint;
959 // Date creation
960 if (!empty($arrayfields['sp.datec']['checked'])) {
961 print '<td class="liste_titre">';
962 print '</td>';
963 }
964 // Date modification
965 if (!empty($arrayfields['sp.tms']['checked'])) {
966 print '<td class="liste_titre">';
967 print '</td>';
968 }
969 if (!empty($arrayfields['sp.note_public']['checked'])) {
970 // Note public
971 print '<td class="liste_titre">';
972 print '<input class="flat maxwidth75" type="text" name="search_note_public" value="'.dol_escape_htmltag($search_note_public).'">';
973 print '</td>';
974 }
975 if (!empty($arrayfields['sp.note_private']['checked'])) {
976 // Note private
977 print '<td class="liste_titre">';
978 print '<input class="flat maxwidth75" type="text" name="search_note_private" value="'.dol_escape_htmltag($search_note_private).'">';
979 print '</td>';
980 }
981 // Status
982 if (!empty($arrayfields['sp.fk_statut']['checked'])) {
983 print '<td class="liste_titre center parentonrightofpage">';
984 $formpropal->selectProposalStatus($search_status, 1, 0, 1, 'supplier', 'search_status', 'search_status width100 onrightofpage');
985 print '</td>';
986 }
987 // Action column
988 if (!$conf->main_checkbox_left_column) {
989 print '<td class="liste_titre maxwidthsearch">';
990 $searchpicto = $form->showFilterButtons();
991 print $searchpicto;
992 print '</td>';
993 }
994
995 print "</tr>\n";
996
997 $totalarray = array();
998 $totalarray['nbfield'] = 0;
999
1000 // Fields title
1001 print '<tr class="liste_titre">';
1002 if ($conf->main_checkbox_left_column) {
1003 print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
1004 $totalarray['nbfield']++;
1005 }
1006 if (!empty($arrayfields['sp.ref']['checked'])) {
1007 print_liste_field_titre($arrayfields['sp.ref']['label'], $_SERVER["PHP_SELF"], 'sp.ref', '', $param, '', $sortfield, $sortorder);
1008 $totalarray['nbfield']++;
1009 }
1010
1011 if (!empty($arrayfields['sp.fk_projet']['checked'])) {
1012 print_liste_field_titre($arrayfields['sp.fk_projet']['label'], $_SERVER["PHP_SELF"], "p.ref", "", $param, '', $sortfield, $sortorder);
1013 $totalarray['nbfield']++;
1014 }
1015
1016 if (!empty($arrayfields['s.nom']['checked'])) {
1017 print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], 's.nom', '', $param, '', $sortfield, $sortorder);
1018 $totalarray['nbfield']++;
1019 }
1020 if (!empty($arrayfields['s.name_alias']['checked'])) {
1021 // @phan-suppress-next-line PhanTypeInvalidDimOffset
1022 print_liste_field_titre($arrayfields['s.name_alias']['label'], $_SERVER["PHP_SELF"], 's.name_alias', '', $param, '', $sortfield, $sortorder);
1023 $totalarray['nbfield']++;
1024 }
1025 if (!empty($arrayfields['s.town']['checked'])) {
1026 print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], 's.town', '', $param, '', $sortfield, $sortorder);
1027 $totalarray['nbfield']++;
1028 }
1029 if (!empty($arrayfields['s.zip']['checked'])) {
1030 print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], 's.zip', '', $param, '', $sortfield, $sortorder);
1031 $totalarray['nbfield']++;
1032 }
1033 if (!empty($arrayfields['state.nom']['checked'])) {
1034 print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder);
1035 $totalarray['nbfield']++;
1036 }
1037 if (!empty($arrayfields['country.code_iso']['checked'])) {
1038 print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, '', $sortfield, $sortorder, 'center ');
1039 $totalarray['nbfield']++;
1040 }
1041 if (!empty($arrayfields['typent.code']['checked'])) {
1042 print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, '', $sortfield, $sortorder, 'center ');
1043 $totalarray['nbfield']++;
1044 }
1045 if (!empty($arrayfields['sp.date_valid']['checked'])) {
1046 print_liste_field_titre($arrayfields['sp.date_valid']['label'], $_SERVER["PHP_SELF"], 'sp.date_valid', '', $param, '', $sortfield, $sortorder, 'center ');
1047 $totalarray['nbfield']++;
1048 }
1049 if (!empty($arrayfields['sp.date_livraison']['checked'])) {
1050 print_liste_field_titre($arrayfields['sp.date_livraison']['label'], $_SERVER["PHP_SELF"], 'sp.date_livraison', '', $param, '', $sortfield, $sortorder, 'center ');
1051 $totalarray['nbfield']++;
1052 }
1053 if (!empty($arrayfields['sp.total_ht']['checked'])) {
1054 print_liste_field_titre($arrayfields['sp.total_ht']['label'], $_SERVER["PHP_SELF"], 'sp.total_ht', '', $param, '', $sortfield, $sortorder, 'right ');
1055 $totalarray['nbfield']++;
1056 }
1057 if (!empty($arrayfields['sp.total_tva']['checked'])) {
1058 print_liste_field_titre($arrayfields['sp.total_tva']['label'], $_SERVER["PHP_SELF"], 'sp.total_tva', '', $param, '', $sortfield, $sortorder, 'right ');
1059 $totalarray['nbfield']++;
1060 }
1061 if (!empty($arrayfields['sp.total_ttc']['checked'])) {
1062 print_liste_field_titre($arrayfields['sp.total_ttc']['label'], $_SERVER["PHP_SELF"], 'sp.total_ttc', '', $param, '', $sortfield, $sortorder, 'right ');
1063 $totalarray['nbfield']++;
1064 }
1065 if (!empty($arrayfields['sp.multicurrency_code']['checked'])) {
1066 print_liste_field_titre($arrayfields['sp.multicurrency_code']['label'], $_SERVER['PHP_SELF'], 'sp.multicurrency_code', '', $param, '', $sortfield, $sortorder);
1067 $totalarray['nbfield']++;
1068 }
1069 if (!empty($arrayfields['sp.multicurrency_tx']['checked'])) {
1070 print_liste_field_titre($arrayfields['sp.multicurrency_tx']['label'], $_SERVER['PHP_SELF'], 'sp.multicurrency_tx', '', $param, '', $sortfield, $sortorder);
1071 $totalarray['nbfield']++;
1072 }
1073 if (!empty($arrayfields['sp.multicurrency_total_ht']['checked'])) {
1074 print_liste_field_titre($arrayfields['sp.multicurrency_total_ht']['label'], $_SERVER['PHP_SELF'], 'sp.multicurrency_total_ht', '', $param, 'class="right"', $sortfield, $sortorder);
1075 $totalarray['nbfield']++;
1076 }
1077 if (!empty($arrayfields['sp.multicurrency_total_vat']['checked'])) {
1078 print_liste_field_titre($arrayfields['sp.multicurrency_total_vat']['label'], $_SERVER['PHP_SELF'], 'sp.multicurrency_total_tva', '', $param, 'class="right"', $sortfield, $sortorder);
1079 $totalarray['nbfield']++;
1080 }
1081 if (!empty($arrayfields['sp.multicurrency_total_ttc']['checked'])) {
1082 print_liste_field_titre($arrayfields['sp.multicurrency_total_ttc']['label'], $_SERVER['PHP_SELF'], 'sp.multicurrency_total_ttc', '', $param, 'class="right"', $sortfield, $sortorder);
1083 $totalarray['nbfield']++;
1084 }
1085 if (!empty($arrayfields['u.login']['checked'])) {
1086 print_liste_field_titre($arrayfields['u.login']['label'], $_SERVER["PHP_SELF"], 'u.login', '', $param, '', $sortfield, $sortorder, 'center ');
1087 $totalarray['nbfield']++;
1088 }
1089 // Extra fields
1090 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
1091 // Hook fields
1092 $parameters = array('arrayfields' => $arrayfields, 'param' => $param, 'sortfield' => $sortfield, 'sortorder' => $sortorder);
1093 $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
1094 print $hookmanager->resPrint;
1095 if (!empty($arrayfields['sp.datec']['checked'])) {
1096 print_liste_field_titre($arrayfields['sp.datec']['label'], $_SERVER["PHP_SELF"], "sp.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
1097 $totalarray['nbfield']++;
1098 }
1099 if (!empty($arrayfields['sp.tms']['checked'])) {
1100 print_liste_field_titre($arrayfields['sp.tms']['label'], $_SERVER["PHP_SELF"], "sp.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap');
1101 $totalarray['nbfield']++;
1102 }
1103 if (!empty($arrayfields['sp.note_public']['checked'])) {
1104 print_liste_field_titre($arrayfields['sp.note_public']['label'], $_SERVER["PHP_SELF"], "sp.note_public", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
1105 $totalarray['nbfield']++;
1106 }
1107 if (!empty($arrayfields['sp.note_private']['checked'])) {
1108 print_liste_field_titre($arrayfields['sp.note_private']['label'], $_SERVER["PHP_SELF"], "sp.note_private", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
1109 $totalarray['nbfield']++;
1110 }
1111 if (!empty($arrayfields['sp.fk_statut']['checked'])) {
1112 print_liste_field_titre($arrayfields['sp.fk_statut']['label'], $_SERVER["PHP_SELF"], "sp.fk_statut", "", $param, '', $sortfield, $sortorder, 'center ');
1113 $totalarray['nbfield']++;
1114 }
1115 // Action
1116 if (!$conf->main_checkbox_left_column) {
1117 print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
1118 $totalarray['nbfield']++;
1119 }
1120 print '</tr>'."\n";
1121
1122 $now = dol_now();
1123 $i = 0;
1124 $total = 0;
1125 $subtotal = 0;
1126
1127 $userstatic = new User($db);
1128 $objectstatic = new SupplierProposal($db);
1129 $projectstatic = new Project($db);
1130
1131 $savnbfield = $totalarray['nbfield'];
1132 $totalarray = array('nbfield' => 0, 'val' => array(), 'pos' => array());
1133 $totalarray['val']['sp.total_ht'] = 0;
1134 $totalarray['val']['sp.total_tva'] = 0;
1135 $totalarray['val']['sp.total_ttc'] = 0;
1136
1137 $imaxinloop = ($limit ? min($num, $limit) : $num);
1138 while ($i < $imaxinloop) {
1139 $obj = $db->fetch_object($resql);
1140
1141 $objectstatic->id = $obj->rowid;
1142 $objectstatic->ref = $obj->ref;
1143 $objectstatic->note_public = $obj->note_public;
1144 $objectstatic->note_private = $obj->note_private;
1145 $objectstatic->status = $obj->status;
1146
1147 // Company
1148 $companystatic->id = $obj->socid;
1149 $companystatic->name = $obj->name;
1150 $companystatic->name_alias = $obj->alias;
1151 $companystatic->client = $obj->client;
1152 $companystatic->code_client = $obj->code_client;
1153
1154 if ($mode == 'kanban') {
1155 if ($i == 0) {
1156 print '<tr class="trkanban"><td colspan="'.$savnbfield.'">';
1157 print '<div class="box-flex-container kanban">';
1158 }
1159 // Output Kanban
1160 // TODO Use a cache on user
1161 $userstatic->fetch($obj->fk_user_author);
1162 $objectstatic->delivery_date = $obj->dp;
1163 print $objectstatic->getKanbanView('', array('thirdparty' => $companystatic, 'userauthor' => $userstatic, 'selected' => in_array($obj->rowid, $arrayofselected)));
1164 if ($i == ($imaxinloop - 1)) {
1165 print '</div>';
1166 print '</td></tr>';
1167 }
1168 } else {
1169 print '<tr class="oddeven row-with-select '.((getDolGlobalInt('MAIN_FINISHED_LINES_OPACITY') == 1 && $obj->status > 1) ? 'opacitymedium' : '').'">';
1170 // Action column
1171 if ($conf->main_checkbox_left_column) {
1172 print '<td class="nowrap center">';
1173 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
1174 $selected = 0;
1175 if (in_array($obj->rowid, $arrayofselected)) {
1176 $selected = 1;
1177 }
1178 print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
1179 }
1180 print '</td>';
1181 }
1182 if (!empty($arrayfields['sp.ref']['checked'])) {
1183 print '<td class="nowraponall">';
1184
1185 print '<table class="nobordernopadding"><tr class="nocellnopadd">';
1186 // Picto + Ref
1187 print '<td class="nobordernopadding nowraponall">';
1188 print $objectstatic->getNomUrl(1, '', '', 0, -1, 1);
1189 print '</td>';
1190 // Warning
1191 $warnornote = '';
1192 //if ($obj->fk_statut == 1 && $db->jdate($obj->date_valid) < ($now - $conf->supplier_proposal->warning_delay)) $warnornote .= img_warning($langs->trans("Late"));
1193 if ($warnornote) {
1194 print '<td style="min-width: 20px" class="nobordernopadding nowrap">';
1195 print $warnornote;
1196 print '</td>';
1197 }
1198 // Other picto tool
1199 print '<td width="16" class="right nobordernopadding hideonsmartphone">';
1200 $filename = dol_sanitizeFileName($obj->ref);
1201 $filedir = $conf->supplier_proposal->dir_output.'/'.dol_sanitizeFileName($obj->ref);
1202 $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->rowid;
1203 print $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir);
1204 print '</td></tr></table>';
1205
1206 print "</td>\n";
1207 if (!$i) {
1208 $totalarray['nbfield']++;
1209 }
1210 }
1211
1212 // Project
1213 if (!empty($arrayfields['sp.fk_projet']['checked'])) {
1214 $projectstatic->id = $obj->project_id;
1215 $projectstatic->ref = $obj->project_ref;
1216 $projectstatic->title = $obj->project_title;
1217 print '<td>';
1218 if ($obj->project_id > 0) {
1219 print $projectstatic->getNomUrl(1);
1220 }
1221 print '</td>';
1222 if (!$i) {
1223 $totalarray['nbfield']++;
1224 }
1225 }
1226
1227 // Thirdparty
1228 if (!empty($arrayfields['s.nom']['checked'])) {
1229 print '<td class="tdoverflowmax150">';
1230 print $companystatic->getNomUrl(1, 'supplier', 0, 0, -1, empty($arrayfields['s.name_alias']['checked']) ? 0 : 1);
1231 print '</td>';
1232 if (!$i) {
1233 $totalarray['nbfield']++;
1234 }
1235 }
1236
1237 // Alias
1238 if (!empty($arrayfields['s.name_alias']['checked'])) {
1239 print '<td class="tdoverflowmax200">';
1240 print $companystatic->name_alias;
1241 print '</td>';
1242 if (!$i) {
1243 $totalarray['nbfield']++;
1244 }
1245 }
1246
1247 // Town
1248 if (!empty($arrayfields['s.town']['checked'])) {
1249 print '<td class="nocellnopadd">';
1250 print $obj->town;
1251 print '</td>';
1252 if (!$i) {
1253 $totalarray['nbfield']++;
1254 }
1255 }
1256 // Zip
1257 if (!empty($arrayfields['s.zip']['checked'])) {
1258 print '<td class="nocellnopadd">';
1259 print $obj->zip;
1260 print '</td>';
1261 if (!$i) {
1262 $totalarray['nbfield']++;
1263 }
1264 }
1265 // State
1266 if (!empty($arrayfields['state.nom']['checked'])) {
1267 print "<td>".$obj->state_name."</td>\n";
1268 if (!$i) {
1269 $totalarray['nbfield']++;
1270 }
1271 }
1272 // Country
1273 if (!empty($arrayfields['country.code_iso']['checked'])) {
1274 print '<td class="center">';
1275 $tmparray = getCountry($obj->fk_pays, 'all');
1276 print $tmparray['label'];
1277 print '</td>';
1278 if (!$i) {
1279 $totalarray['nbfield']++;
1280 }
1281 }
1282 // Type ent
1283 if (!empty($arrayfields['typent.code']['checked'])) {
1284 print '<td class="center">';
1285 if (empty($typenArray) || !is_array($typenArray) || count($typenArray) == 0) {
1286 $typenArray = $formcompany->typent_array(1);
1287 }
1288 print $typenArray[$obj->typent_code];
1289 print '</td>';
1290 if (!$i) {
1291 $totalarray['nbfield']++;
1292 }
1293 }
1294
1295 // Date proposal
1296 if (!empty($arrayfields['sp.date_valid']['checked'])) {
1297 print '<td class="center">';
1298 print dol_print_date($db->jdate($obj->date_valid), 'day');
1299 print "</td>\n";
1300 if (!$i) {
1301 $totalarray['nbfield']++;
1302 }
1303 }
1304
1305 // Date delivery
1306 if (!empty($arrayfields['sp.date_livraison']['checked'])) {
1307 print '<td class="center">';
1308 print dol_print_date($db->jdate($obj->dp), 'day');
1309 print "</td>\n";
1310 if (!$i) {
1311 $totalarray['nbfield']++;
1312 }
1313 }
1314
1315 // Amount HT
1316 if (!empty($arrayfields['sp.total_ht']['checked'])) {
1317 print '<td class="right"><span class="amount">'.price($obj->total_ht)."</span></td>\n";
1318 if (!$i) {
1319 $totalarray['nbfield']++;
1320 }
1321 if (!$i) {
1322 $totalarray['pos'][$totalarray['nbfield']] = 'sp.total_ht';
1323 }
1324 $totalarray['val']['sp.total_ht'] += $obj->total_ht;
1325 }
1326 // Amount VAT
1327 if (!empty($arrayfields['sp.total_tva']['checked'])) {
1328 print '<td class="right"><span class="amount">'.price($obj->total_tva)."</span></td>\n";
1329 if (!$i) {
1330 $totalarray['nbfield']++;
1331 }
1332 if (!$i) {
1333 $totalarray['pos'][$totalarray['nbfield']] = 'sp.total_tva';
1334 }
1335 $totalarray['val']['sp.total_tva'] += $obj->total_tva;
1336 }
1337 // Amount TTC
1338 if (!empty($arrayfields['sp.total_ttc']['checked'])) {
1339 print '<td class="right"><span class="amount">'.price($obj->total_ttc)."</span></td>\n";
1340 if (!$i) {
1341 $totalarray['nbfield']++;
1342 }
1343 if (!$i) {
1344 $totalarray['pos'][$totalarray['nbfield']] = 'sp.total_ttc';
1345 }
1346 $totalarray['val']['sp.total_ttc'] += $obj->total_ttc;
1347 }
1348
1349 // Currency
1350 if (!empty($arrayfields['sp.multicurrency_code']['checked'])) {
1351 print '<td class="nowrap">'.$obj->multicurrency_code.' - '.$langs->trans('Currency'.$obj->multicurrency_code)."</td>\n";
1352 if (!$i) {
1353 $totalarray['nbfield']++;
1354 }
1355 }
1356
1357 // Currency rate
1358 if (!empty($arrayfields['sp.multicurrency_tx']['checked'])) {
1359 print '<td class="nowrap">';
1360 $form->form_multicurrency_rate($_SERVER['PHP_SELF'].'?id='.$obj->rowid, $obj->multicurrency_tx, 'none', $obj->multicurrency_code);
1361 print "</td>\n";
1362 if (!$i) {
1363 $totalarray['nbfield']++;
1364 }
1365 }
1366 // Amount HT
1367 if (!empty($arrayfields['sp.multicurrency_total_ht']['checked'])) {
1368 print '<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_ht)."</span></td>\n";
1369 if (!$i) {
1370 $totalarray['nbfield']++;
1371 }
1372 }
1373 // Amount VAT
1374 if (!empty($arrayfields['sp.multicurrency_total_vat']['checked'])) {
1375 print '<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_vat)."</span></td>\n";
1376 if (!$i) {
1377 $totalarray['nbfield']++;
1378 }
1379 }
1380 // Amount TTC
1381 if (!empty($arrayfields['sp.multicurrency_total_ttc']['checked'])) {
1382 print '<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_ttc)."</span></td>\n";
1383 if (!$i) {
1384 $totalarray['nbfield']++;
1385 }
1386 }
1387
1388 $userstatic->id = $obj->fk_user_author;
1389 $userstatic->login = $obj->login;
1390 $userstatic->status = $obj->ustatus;
1391 $userstatic->lastname = $obj->name;
1392 $userstatic->firstname = $obj->firstname;
1393 $userstatic->photo = $obj->photo;
1394 $userstatic->admin = $obj->admin;
1395 $userstatic->ref = $obj->fk_user_author;
1396 $userstatic->employee = $obj->employee;
1397 $userstatic->email = $obj->uemail;
1398
1399 // Author
1400 if (!empty($arrayfields['u.login']['checked'])) {
1401 print '<td class="tdoverflowmax125">';
1402 if ($userstatic->id > 0) {
1403 print $userstatic->getNomUrl(-1, '', 0, 0, 24, 1, 'login', '', 1);
1404 }
1405 print "</td>\n";
1406 if (!$i) {
1407 $totalarray['nbfield']++;
1408 }
1409 }
1410
1411 // Extra fields
1412 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
1413 // Fields from hook
1414 $parameters = array('arrayfields' => $arrayfields, 'obj' => $obj, 'i' => $i, 'totalarray' => &$totalarray);
1415 $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook
1416 print $hookmanager->resPrint;
1417 // Date creation
1418 if (!empty($arrayfields['sp.datec']['checked'])) {
1419 print '<td class="center nowraponall">';
1420 print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser');
1421 print '</td>';
1422 if (!$i) {
1423 $totalarray['nbfield']++;
1424 }
1425 }
1426 // Date modification
1427 if (!empty($arrayfields['sp.tms']['checked'])) {
1428 print '<td class="center nowraponall">';
1429 print dol_print_date($db->jdate($obj->date_modification), 'dayhour', 'tzuser');
1430 print '</td>';
1431 if (!$i) {
1432 $totalarray['nbfield']++;
1433 }
1434 }
1435 // Note public
1436 if (!empty($arrayfields['f.note_public']['checked'])) {
1437 print '<td class="sensiblehtmlcontent center">';
1438 print '<div class="small lineheightsmall twolinesmax-normallineheight">'.dolPrintHTML(dolGetFirstLineOfText($obj->note_public, 5)).'</div>';
1439 print '</td>';
1440 if (!$i) {
1441 $totalarray['nbfield']++;
1442 }
1443 }
1444 // Note private
1445 if (!empty($arrayfields['f.note_private']['checked'])) {
1446 print '<td class="sensiblehtmlcontent center">';
1447 print '<div class="small lineheightsmall twolinesmax-normallineheight">'.dolPrintHTML(dolGetFirstLineOfText($obj->note_private, 5)).'</div>';
1448 print '</td>';
1449 if (!$i) {
1450 $totalarray['nbfield']++;
1451 }
1452 }
1453 // Status
1454 if (!empty($arrayfields['sp.fk_statut']['checked'])) {
1455 print '<td class="center">'.$objectstatic->getLibStatut(5)."</td>\n";
1456 if (!$i) {
1457 $totalarray['nbfield']++;
1458 }
1459 }
1460
1461 // Action column
1462 if (!$conf->main_checkbox_left_column) {
1463 print '<td class="nowrap center">';
1464 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
1465 $selected = 0;
1466 if (in_array($obj->rowid, $arrayofselected)) {
1467 $selected = 1;
1468 }
1469 print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
1470 }
1471 print '</td>';
1472 }
1473 if (!$i) {
1474 $totalarray['nbfield']++;
1475 }
1476
1477 print "</tr>\n";
1478
1479 $total += $obj->total_ht;
1480 $subtotal += $obj->total_ht;
1481 }
1482 $i++;
1483 }
1484
1485 // Show total line
1486 include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
1487
1488 // If no record found
1489 if ($num == 0) {
1490 $colspan = 1;
1491 foreach ($arrayfields as $key => $val) {
1492 if (!empty($val['checked'])) {
1493 $colspan++;
1494 }
1495 }
1496 print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
1497 }
1498
1499 $db->free($resql);
1500
1501 $parameters = array('arrayfields' => $arrayfields, 'sql' => $sql);
1502 $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook
1503 print $hookmanager->resPrint;
1504
1505 print '</table>'."\n";
1506 print '</div>'."\n";
1507
1508 print '</form>'."\n";
1509
1510 $hidegeneratedfilelistifempty = 1;
1511 if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) {
1512 $hidegeneratedfilelistifempty = 0;
1513 }
1514
1515 // Show list of available documents
1516 $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
1517 $urlsource .= str_replace('&amp;', '&', $param);
1518
1519 $filedir = $diroutputmassaction;
1520
1521 $genallowed = $user->hasRight('supplier_proposal', 'lire');
1522 $delallowed = $user->hasRight('supplier_proposal', 'creer');
1523
1524 print $formfile->showdocuments('massfilesarea_supplier_proposal', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
1525} else {
1527}
1528
1529// End of page
1530llxFooter();
1531$db->close();
$id
Support class for third parties, contacts, members, users or resources.
Definition account.php:47
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
$totalarray
Definition list.php:501
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:91
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:73
Class to manage standard extra fields.
Class to manage forms for categories.
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.
Class to help generate other html components Only common components are here.
Class to manage generation of HTML components for proposal management.
Class to manage projects.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage price ask supplier.
Class to manage Dolibarr users.
getCountry($searchkey, $withcode='', $dbtouse=null, $outputlangs=null, $entconv=1, $searchlabel='')
Return country label, code or id from an id, code or label.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
dol_now($mode='gmt')
Return date for now.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
dolGetFirstLineOfText($text, $nboflines=1, $charset='UTF-8')
Return first line of text.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
natural_search($fields, $value, $mode=0, $nofirstand=0, $sqltoadd='')
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by the value of a given key, which produces ascending (default) or descending out...
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
print_liste_field_titre($name, $file="", $field="", $begin="", $param="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $selectlimitsuffix=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
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.
dolGetButtonTitleSeparator($moreClass="")
Add space between dolGetButtonTitle.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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.