dolibarr 23.0.3
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-2024 Alexandre Spangaro <alexandre@inovea-conseil.com>
15 * Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
16 * Copyright (C) 2024 Benjamin Falière <benjamin.faliere@altairis.fr>
17 * Copyright (C) 2024-2025 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// Nombre de ligne pour choix de produit/service predefinis
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
166$object = new SupplierProposal($db);
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
223$object->fields = dol_sort_array($object->fields, 'position');
224$arrayfields = dol_sort_array($arrayfields, 'position');
225
226// Check only if it's an internal user
227if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) {
228 $search_sale = $user->id;
229}
230
231$result = restrictedArea($user, $module, $objectid, $dbtable);
232
233$permissiontoread = $user->hasRight('supplier_proposal', 'lire');
234$permissiontodelete = $user->hasRight('supplier_proposal', 'supprimer');
235$permissiontoadd = $user->hasRight('supplier_proposal', 'creer');
236
237/*
238 * Actions
239 */
240
241if (GETPOST('cancel', 'alpha')) {
242 $action = 'list';
243 $massaction = '';
244}
245if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
246 $massaction = '';
247}
248
249$parameters = array('socid' => $socid, 'arrayfields' => &$arrayfields);
250$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
251if ($reshook < 0) {
252 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
253}
254
255if (empty($reshook)) {
256 // Selection of new fields
257 include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
258
259 // Purge search criteria
260 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
261 $search_categ = '';
262 $search_user = '';
263 $search_sale = '';
264 $search_ref = '';
265 $search_company = '';
266 $search_company_alias = '';
267 $search_montant_ht = '';
268 $search_montant_vat = '';
269 $search_montant_ttc = '';
270 $search_multicurrency_code = '';
271 $search_multicurrency_tx = '';
272 $search_multicurrency_montant_ht = '';
273 $search_multicurrency_montant_vat = '';
274 $search_multicurrency_montant_ttc = '';
275 $search_project_ref = '';
276 $search_login = '';
277 $search_product_category = '';
278 $searchCategorySupplierPropalList = array();
279 $search_town = '';
280 $search_zip = "";
281 $search_state = "";
282 $search_type = '';
283 $search_country = '';
284 $search_type_thirdparty = '';
285 $search_date_startday = '';
286 $search_date_startmonth = '';
287 $search_date_startyear = '';
288 $search_date_endday = '';
289 $search_date_endmonth = '';
290 $search_date_endyear = '';
291 $search_date_start = '';
292 $search_date_end = '';
293 $search_date_valid_startday = '';
294 $search_date_valid_startmonth = '';
295 $search_date_valid_startyear = '';
296 $search_date_valid_endday = '';
297 $search_date_valid_endmonth = '';
298 $search_date_valid_endyear = '';
299 $search_date_valid_start = '';
300 $search_date_valid_end = '';
301 $search_status = '';
302 $object_statut = '';
303 }
304
305 $objectclass = 'SupplierProposal';
306 $objectlabel = 'SupplierProposals';
307 $uploaddir = $conf->supplier_proposal->dir_output;
308 include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
309}
310
311
312/*
313 * View
314 */
315
316$form = new Form($db);
317$formother = new FormOther($db);
318$formfile = new FormFile($db);
319$formpropal = new FormPropal($db);
320$companystatic = new Societe($db);
321$formcompany = new FormCompany($db);
322
323$now = dol_now();
324
325if ($socid > 0) {
326 $soc = new Societe($db);
327 $soc->fetch($socid);
328 if (empty($search_company)) {
329 $search_company = $soc->name;
330 }
331}
332
333$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
334$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
335
336$title = $langs->trans('ListOfSupplierProposals');
337$help_url = 'EN:Ask_Price_Supplier|FR:Demande_de_prix_fournisseur';
338
339
340// Build and execute select
341// --------------------------------------------------------------------
342$sql = 'SELECT';
343if ($search_all || $search_user > 0) {
344 $sql = 'SELECT DISTINCT';
345}
346$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,';
347$sql .= " typent.code as typent_code,";
348$sql .= " state.code_departement as state_code, state.nom as state_name,";
349$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,';
350$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,';
351$sql .= ' sp.datec as date_creation, sp.tms as date_modification,';
352$sql .= " p.rowid as project_id, p.ref as project_ref, p.title as project_title,";
353$sql .= " u.firstname, u.lastname, u.photo, u.login, u.statut as ustatus, u.admin, u.employee, u.email as uemail";
354// Add fields from extrafields
355if (!empty($extrafields->attributes[$object->table_element]['label'])) {
356 foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
357 $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : '');
358 }
359}
360// Add fields from hooks
361$parameters = array();
362$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook
363$sql .= $hookmanager->resPrint;
364$sql .= ' FROM '.MAIN_DB_PREFIX.'societe as s';
365$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays)";
366$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typent)";
367$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)";
368$sql .= ', '.MAIN_DB_PREFIX.'supplier_proposal as sp';
369if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
370 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (sp.rowid = ef.fk_object)";
371}
372if ($search_all) {
373 $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'supplier_proposaldet as pd ON sp.rowid=pd.fk_supplier_proposal';
374}
375$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'user as u ON sp.fk_user_author = u.rowid';
376$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = sp.fk_projet";
377if ($search_user > 0) {
378 $sql .= ", ".MAIN_DB_PREFIX."element_contact as c";
379 $sql .= ", ".MAIN_DB_PREFIX."c_type_contact as tc";
380}
381$sql .= ' WHERE sp.fk_soc = s.rowid';
382$sql .= ' AND sp.entity IN ('.getEntity('supplier_proposal').')';
383if ($search_town) {
384 $sql .= natural_search('s.town', $search_town);
385}
386if ($search_zip) {
387 $sql .= natural_search("s.zip", $search_zip);
388}
389if ($search_state) {
390 $sql .= natural_search("state.nom", $search_state);
391}
392if ($search_country) {
393 $sql .= " AND s.fk_pays IN (".$db->sanitize($search_country).')';
394}
395if ($search_type_thirdparty != '' && $search_type_thirdparty > 0) {
396 $sql .= " AND s.fk_typent IN (".$db->sanitize($search_type_thirdparty).')';
397}
398if ($search_ref) {
399 $sql .= natural_search('sp.ref', $search_ref);
400}
401if (empty($arrayfields['s.name_alias']['checked']) && $search_company) {
402 $sql .= natural_search(array("s.nom", "s.name_alias"), $search_company);
403} else {
404 if ($search_company) {
405 $sql .= natural_search('s.nom', $search_company);
406 }
407 if ($search_company_alias) {
408 $sql .= natural_search('s.name_alias', $search_company_alias);
409 }
410}
411if ($search_login) {
412 $sql .= natural_search(array('u.lastname', 'u.firstname', 'u.login'), $search_login);
413}
414if ($search_montant_ht) {
415 $sql .= natural_search('sp.total_ht', $search_montant_ht, 1);
416}
417if ($search_montant_vat != '') {
418 $sql .= natural_search("sp.total_tva", $search_montant_vat, 1);
419}
420if ($search_montant_ttc != '') {
421 $sql .= natural_search("sp.total_ttc", $search_montant_ttc, 1);
422}
423if ($search_multicurrency_code != '') {
424 $sql .= " AND sp.multicurrency_code = '".$db->escape($search_multicurrency_code)."'";
425}
426if ($search_multicurrency_tx != '') {
427 $sql .= natural_search('sp.multicurrency_tx', $search_multicurrency_tx, 1);
428}
429if ($search_multicurrency_montant_ht != '') {
430 $sql .= natural_search('sp.multicurrency_total_ht', $search_multicurrency_montant_ht, 1);
431}
432if ($search_multicurrency_montant_vat != '') {
433 $sql .= natural_search('sp.multicurrency_total_tva', $search_multicurrency_montant_vat, 1);
434}
435if ($search_multicurrency_montant_ttc != '') {
436 $sql .= natural_search('sp.multicurrency_total_ttc', $search_multicurrency_montant_ttc, 1);
437}
438if ($search_project_ref != '') {
439 $sql .= natural_search("p.ref", $search_project_ref);
440}
441if ($search_all) {
442 $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
443}
444if ($socid > 0) {
445 $sql .= ' AND s.rowid = '.((int) $socid);
446}
447if ($search_status >= 0 && $search_status != '') {
448 $sql .= ' AND sp.fk_statut IN ('.$db->sanitize($db->escape($search_status)).')';
449}
450if ($search_date_start) {
451 $sql .= " AND sp.date_livraison >= '".$db->idate($search_date_start)."'";
452}
453if ($search_date_end) {
454 $sql .= " AND sp.date_livraison <= '".$db->idate($search_date_end)."'";
455}
456if ($search_date_valid_start) {
457 $sql .= " AND sp.date_valid >= '".$db->idate($search_date_valid_start)."'";
458}
459if ($search_note_public) {
460 $sql .= " AND p.note_public LIKE '%".$db->escape($db->escapeforlike($search_note_public))."%'";
461}
462if ($search_note_private) {
463 $sql .= " AND p.note_private LIKE '%".$db->escape($db->escapeforlike($search_note_private))."%'";
464}
465if ($search_date_valid_end) {
466 $sql .= " AND sp.date_valid <= '".$db->idate($search_date_valid_end)."'";
467}
468/*
469if ($search_sale > 0) {
470 $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $search_sale);
471}*/
472if ($search_user > 0) {
473 $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);
474}
475// Search on sale representative
476if ($search_sale && $search_sale != '-1') {
477 if ($search_sale == -2) {
478 $sql .= " AND NOT EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc WHERE sc.fk_soc = sp.fk_soc)";
479 } elseif ($search_sale > 0) {
480 $sql .= " AND EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc WHERE sc.fk_soc = sp.fk_soc AND sc.fk_user = ".((int) $search_sale).")";
481 }
482}
483// Search for tag/category ($searchCategorySupplierInvoiceList is an array of ID)
484if (!empty($searchCategorySupplierPropalList)) {
485 $searchCategorySupplierPropalSqlList = array();
486 $listofcategoryid = '';
487 foreach ($searchCategorySupplierPropalList as $searchCategorySupplierPropal) {
488 if (intval($searchCategorySupplierPropal) == -2) {
489 $searchCategorySupplierPropalSqlList[] = "NOT EXISTS (SELECT ck.fk_supplier_proposal FROM ".MAIN_DB_PREFIX."categorie_supplier_proposal as ck WHERE sp.rowid = ck.fk_supplier_proposal)";
490 } elseif (intval($searchCategorySupplierPropal) > 0) {
491 if ($searchCategorySupplierPropalOperator == 0) {
492 $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).")";
493 } else {
494 $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategorySupplierPropal);
495 }
496 }
497 }
498 if ($listofcategoryid) {
499 $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)."))";
500 }
501 if ($searchCategorySupplierPropalOperator == 1) {
502 if (!empty($searchCategorySupplierPropalSqlList)) {
503 $sql .= " AND (".implode(' OR ', $searchCategorySupplierPropalSqlList).")";
504 }
505 } else {
506 if (!empty($searchCategorySupplierPropalSqlList)) {
507 $sql .= " AND (".implode(' AND ', $searchCategorySupplierPropalSqlList).")";
508 }
509 }
510}
511// Search for tag/category ($searchCategoryProductList is an array of ID)
512$searchCategoryProductOperator = GETPOSTINT('search_category_product_operator');
513$searchCategoryProductList = array($search_product_category);
514if (!empty($searchCategoryProductList)) {
515 $searchCategoryProductSqlList = array();
516 $listofcategoryid = '';
517 foreach ($searchCategoryProductList as $searchCategoryProduct) {
518 if (intval($searchCategoryProduct) == -2) {
519 $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)";
520 } elseif (intval($searchCategoryProduct) > 0) {
521 if ($searchCategoryProductOperator == 0) {
522 $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).")";
523 } else {
524 $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryProduct);
525 }
526 }
527 }
528 if ($listofcategoryid) {
529 $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)."))";
530 }
531 if ($searchCategoryProductOperator == 1) {
532 if (!empty($searchCategoryProductSqlList)) {
533 $sql .= " AND (".implode(' OR ', $searchCategoryProductSqlList).")";
534 }
535 } else {
536 if (!empty($searchCategoryProductSqlList)) {
537 $sql .= " AND (".implode(' AND ', $searchCategoryProductSqlList).")";
538 }
539 }
540}
541// Add where from extra fields
542include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
543// Add where from hooks
544$parameters = array();
545$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
546$sql .= $hookmanager->resPrint;
547
548$sql .= $db->order($sortfield, $sortorder);
549$sql .= ', sp.ref DESC';
550
551// Count total nb of records
552$nbtotalofrecords = '';
553if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
554 $resql = $db->query($sql);
555 $nbtotalofrecords = $db->num_rows($resql);
556 if (($page * $limit) > (int) $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
557 $page = 0;
558 $offset = 0;
559 }
560}
561
562$sql .= $db->plimit($limit + 1, $offset);
563
564$resql = $db->query($sql);
565if ($resql) {
566 $objectstatic = new SupplierProposal($db);
567 $userstatic = new User($db);
568
569 if ($socid > 0) {
570 $soc = new Societe($db);
571 $soc->fetch($socid);
572 $title = $langs->trans('SupplierProposals').' - '.$soc->name;
573 } else {
574 $title = $langs->trans('SupplierProposals');
575 }
576
577 $num = $db->num_rows($resql);
578
579 $arrayofselected = is_array($toselect) ? $toselect : array();
580
581 if ($num == 1 && getDolGlobalString('MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all) {
582 $obj = $db->fetch_object($resql);
583
584 $id = $obj->rowid;
585
586 header("Location: ".DOL_URL_ROOT.'/supplier_proposal/card.php?id='.$id);
587 exit;
588 }
589
590 // Output page
591 // --------------------------------------------------------------------
592
593 llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'bodyforlist mod-supplierproposal page-list');
594
595 $param = '';
596 if (!empty($mode)) {
597 $param .= '&mode='.urlencode($mode);
598 }
599 if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
600 $param .= '&contextpage='.urlencode($contextpage);
601 }
602 if ($limit > 0 && $limit != $conf->liste_limit) {
603 $param .= '&limit='.((int) $limit);
604 }
605 if ($search_all) {
606 $param .= '&search_all='.urlencode($search_all);
607 }
608 if ($search_date_startday) {
609 $param .= '&search_date_startday='.urlencode((string) ($search_date_startday));
610 }
611 if ($search_date_startmonth) {
612 $param .= '&search_date_startmonth='.urlencode((string) ($search_date_startmonth));
613 }
614 if ($search_date_startyear) {
615 $param .= '&search_date_startyear='.urlencode((string) ($search_date_startyear));
616 }
617 if ($search_date_endday) {
618 $param .= '&search_date_endday='.urlencode((string) ($search_date_endday));
619 }
620 if ($search_date_endmonth) {
621 $param .= '&search_date_endmonth='.urlencode((string) ($search_date_endmonth));
622 }
623 if ($search_date_endyear) {
624 $param .= '&search_date_endyear='.urlencode((string) ($search_date_endyear));
625 }
626 if ($search_date_valid_startday) {
627 $param .= '&search_date_valid_startday='.urlencode((string) ($search_date_valid_startday));
628 }
629 if ($search_date_valid_startmonth) {
630 $param .= '&search_date_valid_startmonth='.urlencode((string) ($search_date_valid_startmonth));
631 }
632 if ($search_date_valid_startyear) {
633 $param .= '&search_date_valid_startyear='.urlencode((string) ($search_date_valid_startyear));
634 }
635 if ($search_date_valid_endday) {
636 $param .= '&search_date_valid_endday='.urlencode((string) ($search_date_valid_endday));
637 }
638 if ($search_date_valid_endmonth) {
639 $param .= '&search_date_valid_endmonth='.urlencode((string) ($search_date_valid_endmonth));
640 }
641 if ($search_date_valid_endyear) {
642 $param .= '&search_date_valid_endyear='.urlencode((string) ($search_date_valid_endyear));
643 }
644 if ($search_ref) {
645 $param .= '&search_ref='.urlencode($search_ref);
646 }
647 if ($search_company) {
648 $param .= '&search_company='.urlencode($search_company);
649 }
650 if ($search_company_alias) {
651 $param .= '&search_company_alias='.urlencode($search_company_alias);
652 }
653 if ($search_user > 0) {
654 $param .= '&search_user='.urlencode((string) ($search_user));
655 }
656 if ($search_sale > 0) {
657 $param .= '&search_sale='.urlencode($search_sale);
658 }
659 if ($search_montant_ht) {
660 $param .= '&search_montant_ht='.urlencode($search_montant_ht);
661 }
662 if ($search_multicurrency_code != '') {
663 $param .= '&search_multicurrency_code='.urlencode($search_multicurrency_code);
664 }
665 if ($search_multicurrency_tx != '') {
666 $param .= '&search_multicurrency_tx='.urlencode($search_multicurrency_tx);
667 }
668 if ($search_multicurrency_montant_ht != '') {
669 $param .= '&search_multicurrency_montant_ht='.urlencode($search_multicurrency_montant_ht);
670 }
671 if ($search_multicurrency_montant_vat != '') {
672 $param .= '&search_multicurrency_montant_vat='.urlencode($search_multicurrency_montant_vat);
673 }
674 if ($search_multicurrency_montant_ttc != '') {
675 $param .= '&search_multicurrency_montant_ttc='.urlencode($search_multicurrency_montant_ttc);
676 }
677 if ($search_login) {
678 $param .= '&search_login='.urlencode($search_login);
679 }
680 if ($searchCategorySupplierPropalOperator == 1) {
681 $param .= "&search_category_supplier_propal_operator=".urlencode((string) ($searchCategorySupplierPropalOperator));
682 }
683 foreach ($searchCategorySupplierPropalList as $searchCategorySupplierPropal) {
684 $param .= "&search_category_supplier_invoice_list[]=".urlencode($searchCategorySupplierPropal);
685 }
686 if ($search_town) {
687 $param .= '&search_town='.urlencode($search_town);
688 }
689 if ($search_zip) {
690 $param .= '&search_zip='.urlencode($search_zip);
691 }
692 if ($socid > 0) {
693 $param .= '&socid='.urlencode((string) ($socid));
694 }
695 if ($search_status != '') {
696 $param .= '&search_status='.urlencode($search_status);
697 }
698 if ($search_project_ref >= 0) {
699 $param .= "&search_project_ref=".urlencode($search_project_ref);
700 }
701 if ($optioncss != '') {
702 $param .= '&optioncss='.urlencode($optioncss);
703 }
704 if ($search_type_thirdparty != '' && $search_type_thirdparty > 0) {
705 $param .= '&search_type_thirdparty='.urlencode((string) ($search_type_thirdparty));
706 }
707 // Add $param from extra fields
708 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
709
710 // List of mass actions available
711 $arrayofmassactions = array(
712 'generate_doc' => img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("ReGeneratePDF"),
713 'builddoc' => img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
714 //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
715 );
716 if (isModEnabled('category') && $user->hasRight('supplier_proposal', 'lire')) {
717 $arrayofmassactions['preaffecttag'] = img_picto('', 'category', 'class="pictofixedwidth"').$langs->trans("AffectTag");
718 }
719 if ($user->hasRight('supplier_proposal', 'supprimer')) {
720 $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
721 }
722 if (in_array($massaction, array('presend', 'predelete'))) {
723 $arrayofmassactions = array();
724 }
725 $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
726
727 $url = DOL_URL_ROOT.'/supplier_proposal/card.php?action=create';
728 if (!empty($socid)) {
729 $url .= '&socid='.$socid;
730 }
731 $newcardbutton = '';
732 $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'));
733 $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'));
734 $newcardbutton .= dolGetButtonTitleSeparator();
735 $newcardbutton .= dolGetButtonTitle($langs->trans('NewAskPrice'), '', 'fa fa-plus-circle', $url, '', $user->hasRight('supplier_proposal', 'creer'));
736
737 // Fields title search
738 print '<form method="POST" id="searchFormList" action="'.dolBuildUrl($_SERVER["PHP_SELF"]).'">';
739 if ($optioncss != '') {
740 print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
741 }
742 print '<input type="hidden" name="token" value="'.newToken().'">';
743 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
744 print '<input type="hidden" name="action" value="list">';
745 print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
746 print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
747 print '<input type="hidden" name="mode" value="'.$mode.'">';
748
749 print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'supplier_proposal', 0, $newcardbutton, '', $limit, 0, 0, 1);
750
751 $topicmail = "SendSupplierProposalRef";
752 $modelmail = "supplier_proposal_send";
753 $objecttmp = new SupplierProposal($db);
754 $trackid = 'spro'.$object->id;
755 include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
756
757 if ($search_all) {
758 foreach ($fieldstosearchall as $key => $val) {
759 $fieldstosearchall[$key] = $langs->trans($val);
760 }
761 print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).implode(', ', $fieldstosearchall).'</div>';
762 }
763
764 $i = 0;
765
766 $moreforfilter = '';
767 if (isModEnabled('category') && $user->hasRight('categorie', 'read')) {
768 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcategory.class.php';
769 $formcategory = new FormCategory($db);
770 $moreforfilter .= $formcategory->getFilterBox(Categorie::TYPE_SUPPLIER_PROPOSAL, $searchCategorySupplierPropalList, 'minwidth300', $searchCategorySupplierPropalOperator ? $searchCategorySupplierPropalOperator : 0);
771 }
772 // If the user can view prospects other than his'
773 if ($user->hasRight('user', 'user', 'lire')) {
774 $langs->load("commercial");
775 $moreforfilter .= '<div class="divsearchfield">';
776 $tmptitle = $langs->trans('ThirdPartiesOfSaleRepresentative');
777 $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, $tmptitle, 'maxwidth250 widthcentpercentminusx');
778 $moreforfilter .= '</div>';
779 }
780 // If the user can view prospects other than his'
781 if ($user->hasRight('user', 'user', 'lire')) {
782 $moreforfilter .= '<div class="divsearchfield">';
783 $tmptitle = $langs->trans('LinkedToSpecificUsers');
784 $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$form->select_dolusers($search_user, 'search_user', $tmptitle, null, 0, '', '', '0', 0, 0, '', 0, '', 'maxwidth250 widthcentpercentminusx');
785 $moreforfilter .= '</div>';
786 }
787 // If the user can view products
788 if (isModEnabled('category') && $user->hasRight('categorie', 'lire') && ($user->hasRight('produit', 'lire') || $user->hasRight('service', 'lire'))) {
789 include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
790 $moreforfilter .= '<div class="divsearchfield">';
791 $tmptitle = $langs->trans('IncludingProductWithTag');
792 $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, '', 'parent', 0, 0, 1);
793 $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);
794 $moreforfilter .= '</div>';
795 }
796 $parameters = array();
797 $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
798 if (empty($reshook)) {
799 $moreforfilter .= $hookmanager->resPrint;
800 } else {
801 $moreforfilter = $hookmanager->resPrint;
802 }
803
804 if (!empty($moreforfilter)) {
805 print '<div class="liste_titre liste_titre_bydiv centpercent">';
806 print $moreforfilter;
807 print '</div>';
808 }
809
810 $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
811 $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')); // This also change content of $arrayfields
812 $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
813
814 print '<div class="div-table-responsive">';
815 print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
816
817 // Fields title search
818 // --------------------------------------------------------------------
819 print '<tr class="liste_titre_filter">';
820 // Action column
821 if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
822 print '<td class="liste_titre maxwidthsearch">';
823 $searchpicto = $form->showFilterButtons('left');
824 print $searchpicto;
825 print '</td>';
826 }
827 if (!empty($arrayfields['sp.ref']['checked'])) {
828 print '<td class="liste_titre">';
829 print '<input class="flat" size="6" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
830 print '</td>';
831 }
832 // Project ref
833 if (!empty($arrayfields['sp.fk_projet']['checked'])) {
834 print '<td class="liste_titre">';
835 print '<input type="text" class="flat" name="search_project_ref" value="'.$search_project_ref.'">';
836 print '</td>';
837 }
838 if (!empty($arrayfields['s.nom']['checked'])) {
839 print '<td class="liste_titre left">';
840 print '<input class="flat" type="text" size="12" name="search_company" value="'.dol_escape_htmltag((string) $search_company).'">';
841 print '</td>';
842 }
843 if (!empty($arrayfields['s.name_alias']['checked'])) {
844 print '<td class="liste_titre left">';
845 print '<input class="flat" type="text" size="12" name="search_company_alias" value="'.dol_escape_htmltag($search_company_alias).'">';
846 print '</td>';
847 }
848 if (!empty($arrayfields['s.town']['checked'])) {
849 print '<td class="liste_titre"><input class="flat" type="text" size="6" name="search_town" value="'.$search_town.'"></td>';
850 }
851 if (!empty($arrayfields['s.zip']['checked'])) {
852 print '<td class="liste_titre"><input class="flat" type="text" size="4" name="search_zip" value="'.$search_zip.'"></td>';
853 }
854 // State
855 if (!empty($arrayfields['state.nom']['checked'])) {
856 print '<td class="liste_titre">';
857 print '<input class="flat" size="4" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).'">';
858 print '</td>';
859 }
860 // Country
861 if (!empty($arrayfields['country.code_iso']['checked'])) {
862 print '<td class="liste_titre center">';
863 print $form->select_country($search_country, 'search_country', '', 0, 'minwidth100imp maxwidth100');
864 print '</td>';
865 }
866 // Company type
867 if (!empty($arrayfields['typent.code']['checked'])) {
868 print '<td class="liste_titre maxwidthonsmartphone center">';
869 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' : $conf->global->SOCIETE_SORT_ON_TYPEENT), '', 1);
870 print '</td>';
871 }
872 // Date
873 if (!empty($arrayfields['sp.date_valid']['checked'])) {
874 print '<td class="liste_titre center">';
875 print '<div class="nowrapfordate">';
876 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'));
877 print '</div>';
878 print '<div class="nowrapfordate">';
879 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'));
880 print '</div>';
881 print '</td>';
882 }
883 // Date
884 if (!empty($arrayfields['sp.date_livraison']['checked'])) {
885 print '<td class="liste_titre center">';
886 print '<div class="nowrapfordate">';
887 print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
888 print '</div>';
889 print '<div class="nowrapfordate">';
890 print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
891 print '</div>';
892 print '</td>';
893 }
894
895 if (!empty($arrayfields['sp.total_ht']['checked'])) {
896 // Amount
897 print '<td class="liste_titre right">';
898 print '<input class="flat" type="text" size="5" name="search_montant_ht" value="'.dol_escape_htmltag($search_montant_ht).'">';
899 print '</td>';
900 }
901 if (!empty($arrayfields['sp.total_tva']['checked'])) {
902 // Amount
903 print '<td class="liste_titre right">';
904 print '<input class="flat" type="text" size="5" name="search_montant_vat" value="'.dol_escape_htmltag($search_montant_vat).'">';
905 print '</td>';
906 }
907 if (!empty($arrayfields['sp.total_ttc']['checked'])) {
908 // Amount
909 print '<td class="liste_titre right">';
910 print '<input class="flat" type="text" size="5" name="search_montant_ttc" value="'.dol_escape_htmltag($search_montant_ttc).'">';
911 print '</td>';
912 }
913 if (!empty($arrayfields['sp.multicurrency_code']['checked'])) {
914 // Currency
915 print '<td class="liste_titre">';
916 print $form->selectMultiCurrency($search_multicurrency_code, 'search_multicurrency_code', 1);
917 print '</td>';
918 }
919 if (!empty($arrayfields['sp.multicurrency_tx']['checked'])) {
920 // Currency rate
921 print '<td class="liste_titre">';
922 print '<input class="flat" type="text" size="4" name="search_multicurrency_tx" value="'.dol_escape_htmltag($search_multicurrency_tx).'">';
923 print '</td>';
924 }
925 if (!empty($arrayfields['sp.multicurrency_total_ht']['checked'])) {
926 // Amount
927 print '<td class="liste_titre right">';
928 print '<input class="flat" type="text" size="4" name="search_multicurrency_montant_ht" value="'.dol_escape_htmltag($search_multicurrency_montant_ht).'">';
929 print '</td>';
930 }
931 if (!empty($arrayfields['sp.multicurrency_total_vat']['checked'])) {
932 // Amount
933 print '<td class="liste_titre right">';
934 print '<input class="flat" type="text" size="4" name="search_multicurrency_montant_vat" value="'.dol_escape_htmltag($search_multicurrency_montant_vat).'">';
935 print '</td>';
936 }
937 if (!empty($arrayfields['sp.multicurrency_total_ttc']['checked'])) {
938 // Amount
939 print '<td class="liste_titre right">';
940 print '<input class="flat" type="text" size="4" name="search_multicurrency_montant_ttc" value="'.dol_escape_htmltag($search_multicurrency_montant_ttc).'">';
941 print '</td>';
942 }
943 if (!empty($arrayfields['u.login']['checked'])) {
944 // Author
945 print '<td class="liste_titre center">';
946 print '<input class="flat" size="4" type="text" name="search_login" value="'.dol_escape_htmltag($search_login).'">';
947 print '</td>';
948 }
949 // Extra fields
950 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
951 // Fields from hook
952 $parameters = array('arrayfields' => $arrayfields);
953 $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
954 print $hookmanager->resPrint;
955 // Date creation
956 if (!empty($arrayfields['sp.datec']['checked'])) {
957 print '<td class="liste_titre">';
958 print '</td>';
959 }
960 // Date modification
961 if (!empty($arrayfields['sp.tms']['checked'])) {
962 print '<td class="liste_titre">';
963 print '</td>';
964 }
965 if (!empty($arrayfields['sp.note_public']['checked'])) {
966 // Note public
967 print '<td class="liste_titre">';
968 print '<input class="flat maxwidth75" type="text" name="search_note_public" value="'.dol_escape_htmltag($search_note_public).'">';
969 print '</td>';
970 }
971 if (!empty($arrayfields['sp.note_private']['checked'])) {
972 // Note private
973 print '<td class="liste_titre">';
974 print '<input class="flat maxwidth75" type="text" name="search_note_private" value="'.dol_escape_htmltag($search_note_private).'">';
975 print '</td>';
976 }
977 // Status
978 if (!empty($arrayfields['sp.fk_statut']['checked'])) {
979 print '<td class="liste_titre center parentonrightofpage">';
980 $formpropal->selectProposalStatus($search_status, 1, 0, 1, 'supplier', 'search_status', 'search_status width100 onrightofpage');
981 print '</td>';
982 }
983 // Action column
984 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
985 print '<td class="liste_titre maxwidthsearch">';
986 $searchpicto = $form->showFilterButtons();
987 print $searchpicto;
988 print '</td>';
989 }
990
991 print "</tr>\n";
992
993 $totalarray = array();
994 $totalarray['nbfield'] = 0;
995
996 // Fields title
997 print '<tr class="liste_titre">';
998 if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
999 print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
1000 $totalarray['nbfield']++;
1001 }
1002 if (!empty($arrayfields['sp.ref']['checked'])) {
1003 print_liste_field_titre($arrayfields['sp.ref']['label'], $_SERVER["PHP_SELF"], 'sp.ref', '', $param, '', $sortfield, $sortorder);
1004 $totalarray['nbfield']++;
1005 }
1006
1007 if (!empty($arrayfields['sp.fk_projet']['checked'])) {
1008 print_liste_field_titre($arrayfields['sp.fk_projet']['label'], $_SERVER["PHP_SELF"], "p.ref", "", $param, '', $sortfield, $sortorder);
1009 $totalarray['nbfield']++;
1010 }
1011
1012 if (!empty($arrayfields['s.nom']['checked'])) {
1013 print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], 's.nom', '', $param, '', $sortfield, $sortorder);
1014 $totalarray['nbfield']++;
1015 }
1016 if (!empty($arrayfields['s.name_alias']['checked'])) {
1017 // @phan-suppress-next-line PhanTypeInvalidDimOffset
1018 print_liste_field_titre($arrayfields['s.name_alias']['label'], $_SERVER["PHP_SELF"], 's.name_alias', '', $param, '', $sortfield, $sortorder);
1019 $totalarray['nbfield']++;
1020 }
1021 if (!empty($arrayfields['s.town']['checked'])) {
1022 print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], 's.town', '', $param, '', $sortfield, $sortorder);
1023 $totalarray['nbfield']++;
1024 }
1025 if (!empty($arrayfields['s.zip']['checked'])) {
1026 print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], 's.zip', '', $param, '', $sortfield, $sortorder);
1027 $totalarray['nbfield']++;
1028 }
1029 if (!empty($arrayfields['state.nom']['checked'])) {
1030 print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder);
1031 $totalarray['nbfield']++;
1032 }
1033 if (!empty($arrayfields['country.code_iso']['checked'])) {
1034 print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, '', $sortfield, $sortorder, 'center ');
1035 $totalarray['nbfield']++;
1036 }
1037 if (!empty($arrayfields['typent.code']['checked'])) {
1038 print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, '', $sortfield, $sortorder, 'center ');
1039 $totalarray['nbfield']++;
1040 }
1041 if (!empty($arrayfields['sp.date_valid']['checked'])) {
1042 print_liste_field_titre($arrayfields['sp.date_valid']['label'], $_SERVER["PHP_SELF"], 'sp.date_valid', '', $param, '', $sortfield, $sortorder, 'center ');
1043 $totalarray['nbfield']++;
1044 }
1045 if (!empty($arrayfields['sp.date_livraison']['checked'])) {
1046 print_liste_field_titre($arrayfields['sp.date_livraison']['label'], $_SERVER["PHP_SELF"], 'sp.date_livraison', '', $param, '', $sortfield, $sortorder, 'center ');
1047 $totalarray['nbfield']++;
1048 }
1049 if (!empty($arrayfields['sp.total_ht']['checked'])) {
1050 print_liste_field_titre($arrayfields['sp.total_ht']['label'], $_SERVER["PHP_SELF"], 'sp.total_ht', '', $param, '', $sortfield, $sortorder, 'right ');
1051 $totalarray['nbfield']++;
1052 }
1053 if (!empty($arrayfields['sp.total_tva']['checked'])) {
1054 print_liste_field_titre($arrayfields['sp.total_tva']['label'], $_SERVER["PHP_SELF"], 'sp.total_tva', '', $param, '', $sortfield, $sortorder, 'right ');
1055 $totalarray['nbfield']++;
1056 }
1057 if (!empty($arrayfields['sp.total_ttc']['checked'])) {
1058 print_liste_field_titre($arrayfields['sp.total_ttc']['label'], $_SERVER["PHP_SELF"], 'sp.total_ttc', '', $param, '', $sortfield, $sortorder, 'right ');
1059 $totalarray['nbfield']++;
1060 }
1061 if (!empty($arrayfields['sp.multicurrency_code']['checked'])) {
1062 print_liste_field_titre($arrayfields['sp.multicurrency_code']['label'], $_SERVER['PHP_SELF'], 'sp.multicurrency_code', '', $param, '', $sortfield, $sortorder);
1063 $totalarray['nbfield']++;
1064 }
1065 if (!empty($arrayfields['sp.multicurrency_tx']['checked'])) {
1066 print_liste_field_titre($arrayfields['sp.multicurrency_tx']['label'], $_SERVER['PHP_SELF'], 'sp.multicurrency_tx', '', $param, '', $sortfield, $sortorder);
1067 $totalarray['nbfield']++;
1068 }
1069 if (!empty($arrayfields['sp.multicurrency_total_ht']['checked'])) {
1070 print_liste_field_titre($arrayfields['sp.multicurrency_total_ht']['label'], $_SERVER['PHP_SELF'], 'sp.multicurrency_total_ht', '', $param, 'class="right"', $sortfield, $sortorder);
1071 $totalarray['nbfield']++;
1072 }
1073 if (!empty($arrayfields['sp.multicurrency_total_vat']['checked'])) {
1074 print_liste_field_titre($arrayfields['sp.multicurrency_total_vat']['label'], $_SERVER['PHP_SELF'], 'sp.multicurrency_total_tva', '', $param, 'class="right"', $sortfield, $sortorder);
1075 $totalarray['nbfield']++;
1076 }
1077 if (!empty($arrayfields['sp.multicurrency_total_ttc']['checked'])) {
1078 print_liste_field_titre($arrayfields['sp.multicurrency_total_ttc']['label'], $_SERVER['PHP_SELF'], 'sp.multicurrency_total_ttc', '', $param, 'class="right"', $sortfield, $sortorder);
1079 $totalarray['nbfield']++;
1080 }
1081 if (!empty($arrayfields['u.login']['checked'])) {
1082 print_liste_field_titre($arrayfields['u.login']['label'], $_SERVER["PHP_SELF"], 'u.login', '', $param, '', $sortfield, $sortorder, 'center ');
1083 $totalarray['nbfield']++;
1084 }
1085 // Extra fields
1086 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
1087 // Hook fields
1088 $parameters = array('arrayfields' => $arrayfields, 'param' => $param, 'sortfield' => $sortfield, 'sortorder' => $sortorder);
1089 $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
1090 print $hookmanager->resPrint;
1091 if (!empty($arrayfields['sp.datec']['checked'])) {
1092 print_liste_field_titre($arrayfields['sp.datec']['label'], $_SERVER["PHP_SELF"], "sp.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
1093 $totalarray['nbfield']++;
1094 }
1095 if (!empty($arrayfields['sp.tms']['checked'])) {
1096 print_liste_field_titre($arrayfields['sp.tms']['label'], $_SERVER["PHP_SELF"], "sp.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap');
1097 $totalarray['nbfield']++;
1098 }
1099 if (!empty($arrayfields['sp.note_public']['checked'])) {
1100 print_liste_field_titre($arrayfields['sp.note_public']['label'], $_SERVER["PHP_SELF"], "sp.note_public", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
1101 $totalarray['nbfield']++;
1102 }
1103 if (!empty($arrayfields['sp.note_private']['checked'])) {
1104 print_liste_field_titre($arrayfields['sp.note_private']['label'], $_SERVER["PHP_SELF"], "sp.note_private", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
1105 $totalarray['nbfield']++;
1106 }
1107 if (!empty($arrayfields['sp.fk_statut']['checked'])) {
1108 print_liste_field_titre($arrayfields['sp.fk_statut']['label'], $_SERVER["PHP_SELF"], "sp.fk_statut", "", $param, '', $sortfield, $sortorder, 'center ');
1109 $totalarray['nbfield']++;
1110 }
1111 // Action
1112 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1113 print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
1114 $totalarray['nbfield']++;
1115 }
1116 print '</tr>'."\n";
1117
1118 $now = dol_now();
1119 $i = 0;
1120 $total = 0;
1121 $subtotal = 0;
1122
1123 $userstatic = new User($db);
1124 $objectstatic = new SupplierProposal($db);
1125 $projectstatic = new Project($db);
1126
1127 $savnbfield = $totalarray['nbfield'];
1128 $totalarray = array('nbfield' => 0, 'val' => array(), 'pos' => array());
1129 $totalarray['val']['sp.total_ht'] = 0;
1130 $totalarray['val']['sp.total_tva'] = 0;
1131 $totalarray['val']['sp.total_ttc'] = 0;
1132
1133 $imaxinloop = ($limit ? min($num, $limit) : $num);
1134 while ($i < $imaxinloop) {
1135 $obj = $db->fetch_object($resql);
1136
1137 $objectstatic->id = $obj->rowid;
1138 $objectstatic->ref = $obj->ref;
1139 $objectstatic->note_public = $obj->note_public;
1140 $objectstatic->note_private = $obj->note_private;
1141 $objectstatic->status = $obj->status;
1142
1143 // Company
1144 $companystatic->id = $obj->socid;
1145 $companystatic->name = $obj->name;
1146 $companystatic->name_alias = $obj->alias;
1147 $companystatic->client = $obj->client;
1148 $companystatic->code_client = $obj->code_client;
1149
1150 if ($mode == 'kanban') {
1151 if ($i == 0) {
1152 print '<tr class="trkanban"><td colspan="'.$savnbfield.'">';
1153 print '<div class="box-flex-container kanban">';
1154 }
1155 // Output Kanban
1156 // TODO Use a cache on user
1157 $userstatic->fetch($obj->fk_user_author);
1158 $objectstatic->delivery_date = $obj->dp;
1159 print $objectstatic->getKanbanView('', array('thirdparty' => $companystatic, 'userauthor' => $userstatic, 'selected' => in_array($obj->rowid, $arrayofselected)));
1160 if ($i == ($imaxinloop - 1)) {
1161 print '</div>';
1162 print '</td></tr>';
1163 }
1164 } else {
1165 print '<tr class="oddeven row-with-select '.((getDolGlobalInt('MAIN_FINISHED_LINES_OPACITY') == 1 && $obj->status > 1) ? 'opacitymedium' : '').'">';
1166 // Action column
1167 if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1168 print '<td class="nowrap center">';
1169 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
1170 $selected = 0;
1171 if (in_array($obj->rowid, $arrayofselected)) {
1172 $selected = 1;
1173 }
1174 print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
1175 }
1176 print '</td>';
1177 }
1178 if (!empty($arrayfields['sp.ref']['checked'])) {
1179 print '<td class="nowraponall">';
1180
1181 print '<table class="nobordernopadding"><tr class="nocellnopadd">';
1182 // Picto + Ref
1183 print '<td class="nobordernopadding nowraponall">';
1184 print $objectstatic->getNomUrl(1, '', '', 0, -1, 1);
1185 print '</td>';
1186 // Warning
1187 $warnornote = '';
1188 //if ($obj->fk_statut == 1 && $db->jdate($obj->date_valid) < ($now - $conf->supplier_proposal->warning_delay)) $warnornote .= img_warning($langs->trans("Late"));
1189 if ($warnornote) {
1190 print '<td style="min-width: 20px" class="nobordernopadding nowrap">';
1191 print $warnornote;
1192 print '</td>';
1193 }
1194 // Other picto tool
1195 print '<td width="16" class="right nobordernopadding hideonsmartphone">';
1196 $filename = dol_sanitizeFileName($obj->ref);
1197 $filedir = $conf->supplier_proposal->dir_output.'/'.dol_sanitizeFileName($obj->ref);
1198 $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->rowid;
1199 print $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir);
1200 print '</td></tr></table>';
1201
1202 print "</td>\n";
1203 if (!$i) {
1204 $totalarray['nbfield']++;
1205 }
1206 }
1207
1208 // Project
1209 if (!empty($arrayfields['sp.fk_projet']['checked'])) {
1210 $projectstatic->id = $obj->project_id;
1211 $projectstatic->ref = $obj->project_ref;
1212 $projectstatic->title = $obj->project_title;
1213 print '<td>';
1214 if ($obj->project_id > 0) {
1215 print $projectstatic->getNomUrl(1);
1216 }
1217 print '</td>';
1218 if (!$i) {
1219 $totalarray['nbfield']++;
1220 }
1221 }
1222
1223 // Thirdparty
1224 if (!empty($arrayfields['s.nom']['checked'])) {
1225 print '<td class="tdoverflowmax150">';
1226 print $companystatic->getNomUrl(1, 'supplier', 0, 0, -1, empty($arrayfields['s.name_alias']['checked']) ? 0 : 1);
1227 print '</td>';
1228 if (!$i) {
1229 $totalarray['nbfield']++;
1230 }
1231 }
1232
1233 // Alias
1234 if (!empty($arrayfields['s.name_alias']['checked'])) {
1235 print '<td class="tdoverflowmax200">';
1236 print $companystatic->name_alias;
1237 print '</td>';
1238 if (!$i) {
1239 $totalarray['nbfield']++;
1240 }
1241 }
1242
1243 // Town
1244 if (!empty($arrayfields['s.town']['checked'])) {
1245 print '<td class="nocellnopadd">';
1246 print $obj->town;
1247 print '</td>';
1248 if (!$i) {
1249 $totalarray['nbfield']++;
1250 }
1251 }
1252 // Zip
1253 if (!empty($arrayfields['s.zip']['checked'])) {
1254 print '<td class="nocellnopadd">';
1255 print $obj->zip;
1256 print '</td>';
1257 if (!$i) {
1258 $totalarray['nbfield']++;
1259 }
1260 }
1261 // State
1262 if (!empty($arrayfields['state.nom']['checked'])) {
1263 print "<td>".$obj->state_name."</td>\n";
1264 if (!$i) {
1265 $totalarray['nbfield']++;
1266 }
1267 }
1268 // Country
1269 if (!empty($arrayfields['country.code_iso']['checked'])) {
1270 print '<td class="center">';
1271 $tmparray = getCountry($obj->fk_pays, 'all');
1272 print $tmparray['label'];
1273 print '</td>';
1274 if (!$i) {
1275 $totalarray['nbfield']++;
1276 }
1277 }
1278 // Type ent
1279 if (!empty($arrayfields['typent.code']['checked'])) {
1280 print '<td class="center">';
1281 if (empty($typenArray) || !is_array($typenArray) || count($typenArray) == 0) {
1282 $typenArray = $formcompany->typent_array(1);
1283 }
1284 print $typenArray[$obj->typent_code];
1285 print '</td>';
1286 if (!$i) {
1287 $totalarray['nbfield']++;
1288 }
1289 }
1290
1291 // Date proposal
1292 if (!empty($arrayfields['sp.date_valid']['checked'])) {
1293 print '<td class="center">';
1294 print dol_print_date($db->jdate($obj->date_valid), 'day');
1295 print "</td>\n";
1296 if (!$i) {
1297 $totalarray['nbfield']++;
1298 }
1299 }
1300
1301 // Date delivery
1302 if (!empty($arrayfields['sp.date_livraison']['checked'])) {
1303 print '<td class="center">';
1304 print dol_print_date($db->jdate($obj->dp), 'day');
1305 print "</td>\n";
1306 if (!$i) {
1307 $totalarray['nbfield']++;
1308 }
1309 }
1310
1311 // Amount HT
1312 if (!empty($arrayfields['sp.total_ht']['checked'])) {
1313 print '<td class="right"><span class="amount">'.price($obj->total_ht)."</span></td>\n";
1314 if (!$i) {
1315 $totalarray['nbfield']++;
1316 }
1317 if (!$i) {
1318 $totalarray['pos'][$totalarray['nbfield']] = 'sp.total_ht';
1319 }
1320 $totalarray['val']['sp.total_ht'] += $obj->total_ht;
1321 }
1322 // Amount VAT
1323 if (!empty($arrayfields['sp.total_tva']['checked'])) {
1324 print '<td class="right"><span class="amount">'.price($obj->total_tva)."</span></td>\n";
1325 if (!$i) {
1326 $totalarray['nbfield']++;
1327 }
1328 if (!$i) {
1329 $totalarray['pos'][$totalarray['nbfield']] = 'sp.total_tva';
1330 }
1331 $totalarray['val']['sp.total_tva'] += $obj->total_tva;
1332 }
1333 // Amount TTC
1334 if (!empty($arrayfields['sp.total_ttc']['checked'])) {
1335 print '<td class="right"><span class="amount">'.price($obj->total_ttc)."</span></td>\n";
1336 if (!$i) {
1337 $totalarray['nbfield']++;
1338 }
1339 if (!$i) {
1340 $totalarray['pos'][$totalarray['nbfield']] = 'sp.total_ttc';
1341 }
1342 $totalarray['val']['sp.total_ttc'] += $obj->total_ttc;
1343 }
1344
1345 // Currency
1346 if (!empty($arrayfields['sp.multicurrency_code']['checked'])) {
1347 print '<td class="nowrap">'.$obj->multicurrency_code.' - '.$langs->trans('Currency'.$obj->multicurrency_code)."</td>\n";
1348 if (!$i) {
1349 $totalarray['nbfield']++;
1350 }
1351 }
1352
1353 // Currency rate
1354 if (!empty($arrayfields['sp.multicurrency_tx']['checked'])) {
1355 print '<td class="nowrap">';
1356 $form->form_multicurrency_rate($_SERVER['PHP_SELF'].'?id='.$obj->rowid, $obj->multicurrency_tx, 'none', $obj->multicurrency_code);
1357 print "</td>\n";
1358 if (!$i) {
1359 $totalarray['nbfield']++;
1360 }
1361 }
1362 // Amount HT
1363 if (!empty($arrayfields['sp.multicurrency_total_ht']['checked'])) {
1364 print '<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_ht)."</span></td>\n";
1365 if (!$i) {
1366 $totalarray['nbfield']++;
1367 }
1368 }
1369 // Amount VAT
1370 if (!empty($arrayfields['sp.multicurrency_total_vat']['checked'])) {
1371 print '<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_vat)."</span></td>\n";
1372 if (!$i) {
1373 $totalarray['nbfield']++;
1374 }
1375 }
1376 // Amount TTC
1377 if (!empty($arrayfields['sp.multicurrency_total_ttc']['checked'])) {
1378 print '<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_ttc)."</span></td>\n";
1379 if (!$i) {
1380 $totalarray['nbfield']++;
1381 }
1382 }
1383
1384 $userstatic->id = $obj->fk_user_author;
1385 $userstatic->login = $obj->login;
1386 $userstatic->status = $obj->ustatus;
1387 $userstatic->lastname = $obj->name;
1388 $userstatic->firstname = $obj->firstname;
1389 $userstatic->photo = $obj->photo;
1390 $userstatic->admin = $obj->admin;
1391 $userstatic->ref = $obj->fk_user_author;
1392 $userstatic->employee = $obj->employee;
1393 $userstatic->email = $obj->uemail;
1394
1395 // Author
1396 if (!empty($arrayfields['u.login']['checked'])) {
1397 print '<td class="tdoverflowmax125">';
1398 if ($userstatic->id > 0) {
1399 print $userstatic->getNomUrl(-1, '', 0, 0, 24, 1, 'login', '', 1);
1400 }
1401 print "</td>\n";
1402 if (!$i) {
1403 $totalarray['nbfield']++;
1404 }
1405 }
1406
1407 // Extra fields
1408 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
1409 // Fields from hook
1410 $parameters = array('arrayfields' => $arrayfields, 'obj' => $obj, 'i' => $i, 'totalarray' => &$totalarray);
1411 $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook
1412 print $hookmanager->resPrint;
1413 // Date creation
1414 if (!empty($arrayfields['sp.datec']['checked'])) {
1415 print '<td class="center nowraponall">';
1416 print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser');
1417 print '</td>';
1418 if (!$i) {
1419 $totalarray['nbfield']++;
1420 }
1421 }
1422 // Date modification
1423 if (!empty($arrayfields['sp.tms']['checked'])) {
1424 print '<td class="center nowraponall">';
1425 print dol_print_date($db->jdate($obj->date_modification), 'dayhour', 'tzuser');
1426 print '</td>';
1427 if (!$i) {
1428 $totalarray['nbfield']++;
1429 }
1430 }
1431 // Note public
1432 if (!empty($arrayfields['f.note_public']['checked'])) {
1433 print '<td class="sensiblehtmlcontent center">';
1434 print '<div class="small lineheightsmall twolinesmax-normallineheight">'.dolPrintHTML(dolGetFirstLineOfText($obj->note_public, 5)).'</div>';
1435 print '</td>';
1436 if (!$i) {
1437 $totalarray['nbfield']++;
1438 }
1439 }
1440 // Note private
1441 if (!empty($arrayfields['f.note_private']['checked'])) {
1442 print '<td class="sensiblehtmlcontent center">';
1443 print '<div class="small lineheightsmall twolinesmax-normallineheight">'.dolPrintHTML(dolGetFirstLineOfText($obj->note_private, 5)).'</div>';
1444 print '</td>';
1445 if (!$i) {
1446 $totalarray['nbfield']++;
1447 }
1448 }
1449 // Status
1450 if (!empty($arrayfields['sp.fk_statut']['checked'])) {
1451 print '<td class="center">'.$objectstatic->getLibStatut(5)."</td>\n";
1452 if (!$i) {
1453 $totalarray['nbfield']++;
1454 }
1455 }
1456
1457 // Action column
1458 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1459 print '<td class="nowrap center">';
1460 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
1461 $selected = 0;
1462 if (in_array($obj->rowid, $arrayofselected)) {
1463 $selected = 1;
1464 }
1465 print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
1466 }
1467 print '</td>';
1468 }
1469 if (!$i) {
1470 $totalarray['nbfield']++;
1471 }
1472
1473 print "</tr>\n";
1474
1475 $total += $obj->total_ht;
1476 $subtotal += $obj->total_ht;
1477 }
1478 $i++;
1479 }
1480
1481 // Show total line
1482 include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
1483
1484 // If no record found
1485 if ($num == 0) {
1486 $colspan = 1;
1487 foreach ($arrayfields as $key => $val) {
1488 if (!empty($val['checked'])) {
1489 $colspan++;
1490 }
1491 }
1492 print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
1493 }
1494
1495 $db->free($resql);
1496
1497 $parameters = array('arrayfields' => $arrayfields, 'sql' => $sql);
1498 $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook
1499 print $hookmanager->resPrint;
1500
1501 print '</table>'."\n";
1502 print '</div>'."\n";
1503
1504 print '</form>'."\n";
1505
1506 $hidegeneratedfilelistifempty = 1;
1507 if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) {
1508 $hidegeneratedfilelistifempty = 0;
1509 }
1510
1511 // Show list of available documents
1512 $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
1513 $urlsource .= str_replace('&amp;', '&', $param);
1514
1515 $filedir = $diroutputmassaction;
1516
1517 $genallowed = $user->hasRight('supplier_proposal', 'lire');
1518 $delallowed = $user->hasRight('supplier_proposal', 'creer');
1519
1520 print $formfile->showdocuments('massfilesarea_supplier_proposal', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
1521} else {
1522 dol_print_error($db);
1523}
1524
1525// End of page
1526llxFooter();
1527$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 export.php:1216
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 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 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.
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...
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)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dolGetFirstLineOfText($text, $nboflines=1, $charset='UTF-8')
Return first line of text.
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
dol_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...
dolGetButtonTitleSeparator($moreClass="")
Add space between dolGetButtonTitle.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
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).
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
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.