dolibarr 25.0.0-alpha
dict.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2004-2018 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
5 * Copyright (C) 2005-2017 Regis Houssin <regis.houssin@inodbox.com>
6 * Copyright (C) 2010-2022 Juanjo Menent <jmenent@2byte.es>
7 * Copyright (C) 2011-2021 Philippe Grand <philippe.grand@atoo-net.com>
8 * Copyright (C) 2011 Remy Younes <ryounes@gmail.com>
9 * Copyright (C) 2012-2015 Marcos García <marcosgdf@gmail.com>
10 * Copyright (C) 2012 Christophe Battarel <christophe.battarel@ltairis.fr>
11 * Copyright (C) 2011-2025 Alexandre Spangaro <alexandre@inovea-conseil.com>
12 * Copyright (C) 2015 Ferran Marcet <fmarcet@2byte.es>
13 * Copyright (C) 2016 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
14 * Copyright (C) 2019-2026 Frédéric France <frederic.france@free.fr>
15 * Copyright (C) 2020-2026 Open-Dsi <support@open-dsi.fr>
16 * Copyright (C) 2024-2025 Charlene Benke <charlene@patas-monkey.com>
17 * Copyright (C) 2024-2026 MDW <mdeweerd@users.noreply.github.com>
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';
49require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
50require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
51require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
52require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
53require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
54require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
55require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
56require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
57require_once DOL_DOCUMENT_ROOT.'/core/lib/socialnetwork.lib.php';
58
59// Constants for IDs of core dictionaries
60const DICT_FORME_JURIDIQUE = 1;
61const DICT_DEPARTEMENTS = 2;
62const DICT_REGIONS = 3;
63const DICT_COUNTRY = 4;
64const DICT_CIVILITY = 5;
65const DICT_ACTIONCOMM = 6;
66const DICT_CHARGESOCIALES = 7;
67const DICT_TYPENT = 8;
68const DICT_CURRENCIES = 9;
69const DICT_TVA = 10;
70const DICT_TYPE_CONTACT = 11;
71const DICT_PAYMENT_TERM = 12;
72const DICT_PAIEMENT = 13;
73const DICT_ECOTAXE = 14;
74const DICT_PAPER_FORMAT = 15;
75const DICT_PROSPECTLEVEL = 16;
76const DICT_TYPE_FEES = 17;
77const DICT_SHIPMENT_MODE = 18;
78const DICT_EFFECTIF = 19;
79const DICT_INPUT_METHOD = 20;
80const DICT_AVAILABILITY = 21;
81const DICT_INPUT_REASON = 22;
82const DICT_REVENUESTAMP = 23;
83const DICT_TYPE_RESOURCE = 24;
84const DICT_TYPE_CONTAINER = 25;
85//const DICT_UNITS = 26;
86const DICT_STCOMM = 27;
87const DICT_HOLIDAY_TYPES = 28;
88const DICT_LEAD_STATUS = 29;
89const DICT_FORMAT_CARDS = 30;
90const DICT_INVOICE_SUBTYPE = 31;
91const DICT_HRM_PUBLIC_HOLIDAY = 32;
92const DICT_HRM_DEPARTMENT = 33;
93const DICT_HRM_FUNCTION = 34;
94const DICT_EXP_TAX_CAT = 35;
95const DICT_EXP_TAX_RANGE = 36;
96const DICT_UNITS = 37;
97const DICT_SOCIALNETWORKS = 38;
98const DICT_PROSPECTCONTACTLEVEL = 39;
99const DICT_STCOMMCONTACT = 40;
100const DICT_TRANSPORT_MODE = 41;
101const DICT_PRODUCT_NATURE = 42;
102const DICT_PRODUCTBATCH_QCSTATUS = 43;
103const DICT_ASSET_DISPOSAL_TYPE = 44;
104
105// Load translation files required by the page
106$langs->loadLangs(array("admin", "main", "companies", "compta", "resource", "holiday", "accountancy", "hrm", "orders", "contracts", "projects", "propal", "bills", "interventions", "ticket"));
107
108$action = GETPOST('action', 'alpha') ? GETPOST('action', 'alpha') : 'view';
109$confirm = GETPOST('confirm', 'alpha');
110
111$id = GETPOSTINT('id');
112$rowid = GETPOST('rowid', 'alpha');
113$entity = GETPOST('entity', 'alpha'); // Do not use GETPOSTINT here. Should be '', 0 or >0.
114$code = GETPOST('code', 'alpha');
115$from = GETPOST('from', 'alpha');
116
117$acts = array();
118$actl = array();
119$acts[0] = "activate";
120$acts[1] = "disable";
121$actl[0] = img_picto($langs->trans("Disabled"), 'switch_off', 'class="size15x"');
122$actl[1] = img_picto($langs->trans("Activated"), 'switch_on', 'class="size15x"');
123
124// Load variable for pagination
125$listlimit = GETPOST('listlimit') > 0 ? GETPOST('listlimit') : $conf->liste_limit; // To avoid too long dictionaries
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 = $listlimit * $page;
134$pageprev = $page - 1;
135$pagenext = $page + 1;
136
137$search_country_id = GETPOST('search_country_id', 'int');
138$search_code = GETPOST('search_code', 'alpha');
139$search_active = GETPOST('search_active', 'alpha');
140
141// Context page must be different for each dictionary id, so the selection of columns to show
142// (saved into user parameters with key MAIN_SELECTEDFIELDS_<contextpage>) is done for each dictionary.
143$contextpage = 'dict'.((int) $id);
144
145// Special case to set a default value for country according to dictionary
146if (!GETPOSTISSET('search_country_id') && $search_country_id == '' && ($id == DICT_DEPARTEMENTS || $id == DICT_REGIONS || $id == DICT_TVA)) { // Not a so good idea to force on current country for all dictionaries. Some tables have entries that are for all countries, we must be able to see them, so this is done for dedicated dictionaries only.
147 $search_country_id = $mysoc->country_id;
148}
149
150// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
151$hookmanager->initHooks(array('admin', 'dictionaryadmin'));
152
153$allowed = $user->admin;
154if ($id == DICT_CHARGESOCIALES && $user->hasRight('accounting', 'chartofaccount')) {
155 $allowed = 1; // Tax page allowed to manager of chart account
156}
157if ($id == DICT_TVA && $user->hasRight('accounting', 'chartofaccount')) {
158 $allowed = 1; // Vat page allowed to manager of chart account
159}
160if ($id == DICT_TYPE_FEES && $user->hasRight('accounting', 'chartofaccount')) {
161 $allowed = 1; // Dictionary with type of expense report and accounting account allowed to manager of chart account
162}
163if (!$allowed) {
165}
166
167$permissiontoadd = $allowed;
168
169
170// This page is a generic page to edit dictionaries
171// Put here declaration of dictionaries properties
172
173// Sort order to show dictionary (0 is space). All other dictionaries (added by modules) will be at end of this.
174$taborder = array(
175 DICT_CURRENCIES, DICT_PAPER_FORMAT, DICT_FORMAT_CARDS, 0,
176 DICT_COUNTRY, DICT_REGIONS, DICT_DEPARTEMENTS, 0,
177 DICT_FORME_JURIDIQUE, DICT_TYPENT, DICT_EFFECTIF, DICT_PROSPECTLEVEL, DICT_PROSPECTCONTACTLEVEL, DICT_STCOMM, DICT_STCOMMCONTACT, DICT_SOCIALNETWORKS, 0,
178 DICT_CIVILITY, DICT_TYPE_CONTACT, 0,
179 DICT_ACTIONCOMM, DICT_TYPE_RESOURCE, 0,
180 DICT_LEAD_STATUS, 0,
181 DICT_HRM_DEPARTMENT, DICT_HRM_FUNCTION, DICT_HRM_PUBLIC_HOLIDAY, DICT_HOLIDAY_TYPES, DICT_TYPE_FEES, DICT_EXP_TAX_CAT, DICT_EXP_TAX_RANGE, 0,
182 DICT_TVA, DICT_INVOICE_SUBTYPE, DICT_REVENUESTAMP, DICT_PAYMENT_TERM, DICT_PAIEMENT, DICT_CHARGESOCIALES, 0,
183 DICT_ECOTAXE, 0,
184 DICT_INPUT_REASON, DICT_INPUT_METHOD, DICT_SHIPMENT_MODE, DICT_AVAILABILITY, DICT_TRANSPORT_MODE, 0,
185 DICT_UNITS, DICT_PRODUCT_NATURE, 0,
186 DICT_PRODUCTBATCH_QCSTATUS, 0,
187 DICT_TYPE_CONTAINER, 0,
188 DICT_ASSET_DISPOSAL_TYPE, 0
189);
190
191// Name of SQL tables of dictionaries
192$tabname = array();
193$tabname[DICT_FORME_JURIDIQUE] = "c_forme_juridique";
194$tabname[DICT_DEPARTEMENTS] = "c_departements";
195$tabname[DICT_REGIONS] = "c_regions";
196$tabname[DICT_COUNTRY] = "c_country";
197$tabname[DICT_CIVILITY] = "c_civility";
198$tabname[DICT_ACTIONCOMM] = "c_actioncomm";
199$tabname[DICT_CHARGESOCIALES] = "c_chargesociales";
200$tabname[DICT_TYPENT] = "c_typent";
201$tabname[DICT_CURRENCIES] = "c_currencies";
202$tabname[DICT_TVA] = "c_tva";
203$tabname[DICT_TYPE_CONTACT] = "c_type_contact";
204$tabname[DICT_PAYMENT_TERM] = "c_payment_term";
205$tabname[DICT_PAIEMENT] = "c_paiement";
206$tabname[DICT_ECOTAXE] = "c_ecotaxe";
207$tabname[DICT_PAPER_FORMAT] = "c_paper_format";
208$tabname[DICT_PROSPECTLEVEL] = "c_prospectlevel";
209$tabname[DICT_TYPE_FEES] = "c_type_fees";
210$tabname[DICT_SHIPMENT_MODE] = "c_shipment_mode";
211$tabname[DICT_EFFECTIF] = "c_effectif";
212$tabname[DICT_INPUT_METHOD] = "c_input_method";
213$tabname[DICT_AVAILABILITY] = "c_availability";
214$tabname[DICT_INPUT_REASON] = "c_input_reason";
215$tabname[DICT_REVENUESTAMP] = "c_revenuestamp";
216$tabname[DICT_TYPE_RESOURCE] = "c_type_resource";
217$tabname[DICT_TYPE_CONTAINER] = "c_type_container";
218//$tabname[DICT_UNITS]= "c_units";
219$tabname[DICT_STCOMM] = "c_stcomm";
220$tabname[DICT_HOLIDAY_TYPES] = "c_holiday_types";
221$tabname[DICT_LEAD_STATUS] = "c_lead_status";
222$tabname[DICT_FORMAT_CARDS] = "c_format_cards";
223$tabname[DICT_INVOICE_SUBTYPE] = "c_invoice_subtype";
224$tabname[DICT_HRM_PUBLIC_HOLIDAY] = "c_hrm_public_holiday";
225$tabname[DICT_HRM_DEPARTMENT] = "c_hrm_department";
226$tabname[DICT_HRM_FUNCTION] = "c_hrm_function";
227$tabname[DICT_EXP_TAX_CAT] = "c_exp_tax_cat";
228$tabname[DICT_EXP_TAX_RANGE] = "c_exp_tax_range";
229$tabname[DICT_UNITS] = "c_units";
230$tabname[DICT_SOCIALNETWORKS] = "c_socialnetworks";
231$tabname[DICT_PROSPECTCONTACTLEVEL] = "c_prospectcontactlevel";
232$tabname[DICT_STCOMMCONTACT] = "c_stcommcontact";
233$tabname[DICT_TRANSPORT_MODE] = "c_transport_mode";
234$tabname[DICT_PRODUCT_NATURE] = "c_product_nature";
235$tabname[DICT_PRODUCTBATCH_QCSTATUS] = "c_productbatch_qcstatus";
236$tabname[DICT_ASSET_DISPOSAL_TYPE] = "c_asset_disposal_type";
237
238// Dictionary labels
239$tablib = array();
240$tablib[DICT_FORME_JURIDIQUE] = "DictionaryCompanyJuridicalType";
241$tablib[DICT_DEPARTEMENTS] = "DictionaryCanton";
242$tablib[DICT_REGIONS] = "DictionaryRegion";
243$tablib[DICT_COUNTRY] = "DictionaryCountry";
244$tablib[DICT_CIVILITY] = "DictionaryCivility";
245$tablib[DICT_ACTIONCOMM] = "DictionaryActions";
246$tablib[DICT_CHARGESOCIALES] = "DictionarySocialContributions";
247$tablib[DICT_TYPENT] = "DictionaryCompanyType";
248$tablib[DICT_CURRENCIES] = "DictionaryCurrency";
249$tablib[DICT_TVA] = "DictionaryVAT";
250$tablib[DICT_TYPE_CONTACT] = "DictionaryTypeContact";
251$tablib[DICT_PAYMENT_TERM] = "DictionaryPaymentConditions";
252$tablib[DICT_PAIEMENT] = "DictionaryPaymentModes";
253$tablib[DICT_ECOTAXE] = "DictionaryEcotaxe";
254$tablib[DICT_PAPER_FORMAT] = "DictionaryPaperFormat";
255$tablib[DICT_PROSPECTLEVEL] = "DictionaryProspectLevel";
256$tablib[DICT_TYPE_FEES] = "DictionaryFees";
257$tablib[DICT_SHIPMENT_MODE] = "DictionarySendingMethods";
258$tablib[DICT_EFFECTIF] = "DictionaryStaff";
259$tablib[DICT_INPUT_METHOD] = "DictionaryOrderMethods";
260$tablib[DICT_AVAILABILITY] = "DictionaryAvailability";
261$tablib[DICT_INPUT_REASON] = "DictionarySource";
262$tablib[DICT_REVENUESTAMP] = "DictionaryRevenueStamp";
263$tablib[DICT_TYPE_RESOURCE] = "DictionaryResourceType";
264$tablib[DICT_TYPE_CONTAINER] = "DictionaryTypeOfContainer";
265//$tablib[DICT_UNITS]= "DictionaryUnits";
266$tablib[DICT_STCOMM] = "DictionaryProspectStatus";
267$tablib[DICT_HOLIDAY_TYPES] = "DictionaryHolidayTypes";
268$tablib[DICT_LEAD_STATUS] = "DictionaryOpportunityStatus";
269$tablib[DICT_FORMAT_CARDS] = "DictionaryFormatCards";
270$tablib[DICT_INVOICE_SUBTYPE] = "DictionaryInvoiceSubtype";
271$tablib[DICT_HRM_PUBLIC_HOLIDAY] = "DictionaryPublicHolidays";
272$tablib[DICT_HRM_DEPARTMENT] = "DictionaryDepartment";
273$tablib[DICT_HRM_FUNCTION] = "DictionaryFunction";
274$tablib[DICT_EXP_TAX_CAT] = "DictionaryExpenseTaxCat";
275$tablib[DICT_EXP_TAX_RANGE] = "DictionaryExpenseTaxRange";
276$tablib[DICT_UNITS] = "DictionaryMeasuringUnits";
277$tablib[DICT_SOCIALNETWORKS] = "DictionarySocialNetworks";
278$tablib[DICT_PROSPECTCONTACTLEVEL] = "DictionaryProspectContactLevel";
279$tablib[DICT_STCOMMCONTACT] = "DictionaryProspectContactStatus";
280$tablib[DICT_TRANSPORT_MODE] = "DictionaryTransportMode";
281$tablib[DICT_PRODUCT_NATURE] = "DictionaryProductNature";
282$tablib[DICT_PRODUCTBATCH_QCSTATUS] = "DictionaryBatchStatus";
283$tablib[DICT_ASSET_DISPOSAL_TYPE] = "DictionaryAssetDisposalType";
284
285// Requests to extract data
286$tabsql = array();
287$tabsql[DICT_FORME_JURIDIQUE] = "SELECT f.rowid as rowid, f.code, f.libelle, c.code as country_code, c.label as country, f.active FROM ".MAIN_DB_PREFIX."c_forme_juridique as f, ".MAIN_DB_PREFIX."c_country as c WHERE f.fk_pays=c.rowid";
288$tabsql[DICT_DEPARTEMENTS] = "SELECT d.rowid as rowid, d.code_departement as code, d.nom as libelle, d.fk_region as region_id, r.nom as region, c.code as country_code, c.label as country, d.active FROM ".MAIN_DB_PREFIX."c_departements as d, ".MAIN_DB_PREFIX."c_regions as r, ".MAIN_DB_PREFIX."c_country as c WHERE d.fk_region=r.code_region and r.fk_pays=c.rowid and r.active=1 and c.active=1";
289$tabsql[DICT_REGIONS] = "SELECT r.rowid as rowid, r.code_region as code, r.nom as libelle, r.fk_pays as country_id, c.code as country_code, c.label as country, r.active FROM ".MAIN_DB_PREFIX."c_regions as r, ".MAIN_DB_PREFIX."c_country as c WHERE r.fk_pays=c.rowid and c.active=1";
290$tabsql[DICT_COUNTRY] = "SELECT c.rowid as rowid, c.code, c.label, c.phone_code, c.trunk_prefix, c.active, c.favorite, c.eec, c.sepa FROM ".MAIN_DB_PREFIX."c_country AS c";
291$tabsql[DICT_CIVILITY] = "SELECT c.rowid as rowid, c.code as code, c.label, c.active FROM ".MAIN_DB_PREFIX."c_civility AS c";
292$tabsql[DICT_ACTIONCOMM] = "SELECT a.id as rowid, a.code as code, a.libelle AS libelle, a.type, a.active, a.module, a.color, a.position FROM ".MAIN_DB_PREFIX."c_actioncomm AS a";
293$tabsql[DICT_CHARGESOCIALES] = "SELECT a.id as rowid, a.code as code, a.libelle AS libelle, a.accountancy_code as accountancy_code, a.deductible as deductible, c.code as country_code, c.label as country, a.fk_pays as country_id, a.active FROM ".MAIN_DB_PREFIX."c_chargesociales AS a, ".MAIN_DB_PREFIX."c_country as c WHERE a.fk_pays = c.rowid and c.active = 1";
294$tabsql[DICT_TYPENT] = "SELECT t.id as rowid, t.code as code, t.libelle, t.fk_country as country_id, c.code as country_code, c.label as country, t.position, t.module, t.active FROM ".MAIN_DB_PREFIX."c_typent as t LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON t.fk_country=c.rowid";
295$tabsql[DICT_CURRENCIES] = "SELECT c.code_iso as code, c.label, c.unicode, c.active FROM ".MAIN_DB_PREFIX."c_currencies AS c";
296$tabsql[DICT_TVA] = "SELECT t.rowid, t.entity, t.code, t.type_vat, t.taux, t.localtax1_type, t.localtax1, t.localtax2_type, t.localtax2, t.einvoice_vatex, c.label as country, c.code as country_code, t.fk_pays as country_id, t.fk_department_buyer as department_buyer_id, db.nom as department_buyer, t.recuperableonly, t.note, t.active, t.accountancy_code_sell, t.accountancy_code_buy, t.use_default FROM "
297 .MAIN_DB_PREFIX."c_tva as t INNER JOIN "
298 .MAIN_DB_PREFIX."c_country as c ON t.fk_pays = c.rowid LEFT JOIN "
299 .MAIN_DB_PREFIX."c_departements as db ON t.fk_department_buyer = db.rowid WHERE t.entity IN ("
300 .getEntity($tabname[DICT_TVA]).")";
301$tabsql[DICT_TYPE_CONTACT] = "SELECT t.rowid as rowid, t.element, t.source, t.code, t.libelle, t.position, t.active FROM ".MAIN_DB_PREFIX."c_type_contact AS t";
302$tabsql[DICT_PAYMENT_TERM] = "SELECT c.rowid as rowid, c.code, c.libelle, c.libelle_facture, c.deposit_percent, c.nbjour, c.type_cdr, c.decalage, c.active, c.sortorder, c.entity FROM ".MAIN_DB_PREFIX."c_payment_term AS c WHERE c.entity IN (".getEntity($tabname[DICT_PAYMENT_TERM]).")";
303$tabsql[DICT_PAIEMENT] = "SELECT c.id as rowid, c.code, c.libelle, c.type, c.accountancy_code, c.active, c.entity FROM ".MAIN_DB_PREFIX."c_paiement AS c WHERE c.entity IN (".getEntity($tabname[DICT_PAIEMENT]).")";
304$tabsql[DICT_ECOTAXE] = "SELECT e.rowid as rowid, e.code as code, e.label, e.price, e.organization, e.fk_pays as country_id, c.code as country_code, c.label as country, e.active FROM ".MAIN_DB_PREFIX."c_ecotaxe AS e, ".MAIN_DB_PREFIX."c_country as c WHERE e.fk_pays=c.rowid and c.active=1";
305$tabsql[DICT_PAPER_FORMAT] = "SELECT t.rowid as rowid, t.code, t.label as libelle, t.width, t.height, t.unit, t.active FROM ".MAIN_DB_PREFIX."c_paper_format as t";
306$tabsql[DICT_PROSPECTLEVEL] = "SELECT t.code, t.label as libelle, t.sortorder, t.active FROM ".MAIN_DB_PREFIX."c_prospectlevel as t";
307$tabsql[DICT_TYPE_FEES] = "SELECT t.id as rowid, t.code, t.label, t.accountancy_code, t.active FROM ".MAIN_DB_PREFIX."c_type_fees as t";
308$tabsql[DICT_SHIPMENT_MODE] = "SELECT t.rowid as rowid, t.code, t.libelle, t.tracking, t.active FROM ".MAIN_DB_PREFIX."c_shipment_mode as t";
309$tabsql[DICT_EFFECTIF] = "SELECT t.id as rowid, t.code, t.libelle, t.active FROM ".MAIN_DB_PREFIX."c_effectif as t";
310$tabsql[DICT_INPUT_METHOD] = "SELECT t.rowid as rowid, t.code, t.libelle, t.active FROM ".MAIN_DB_PREFIX."c_input_method as t";
311$tabsql[DICT_AVAILABILITY] = "SELECT c.rowid as rowid, c.code, c.label, c.type_duration, c.qty, c.active, c.position FROM ".MAIN_DB_PREFIX."c_availability AS c";
312$tabsql[DICT_INPUT_REASON] = "SELECT t.rowid as rowid, t.code, t.label, t.active FROM ".MAIN_DB_PREFIX."c_input_reason as t";
313$tabsql[DICT_REVENUESTAMP] = "SELECT t.rowid as rowid, t.taux, t.revenuestamp_type, c.label as country, c.code as country_code, t.fk_pays as country_id, t.note, t.active, t.accountancy_code_sell, t.accountancy_code_buy FROM ".MAIN_DB_PREFIX."c_revenuestamp as t, ".MAIN_DB_PREFIX."c_country as c WHERE t.fk_pays=c.rowid";
314$tabsql[DICT_TYPE_RESOURCE] = "SELECT t.rowid as rowid, t.code, t.label, t.active FROM ".MAIN_DB_PREFIX."c_type_resource as t";
315$tabsql[DICT_TYPE_CONTAINER] = "SELECT t.rowid as rowid, t.entity, t.code, t.label, t.active, t.module FROM ".MAIN_DB_PREFIX."c_type_container as t WHERE t.entity IN (".getEntity($tabname[DICT_TYPE_CONTAINER]).")";
316//$tabsql[DICT_UNITS]= "SELECT t.rowid as rowid, t.code, t.label, t.short_label, t.active FROM ".MAIN_DB_PREFIX."c_units as t";
317$tabsql[DICT_STCOMM] = "SELECT t.id as rowid, t.code, t.libelle, t.picto, t.active FROM ".MAIN_DB_PREFIX."c_stcomm as t";
318$tabsql[DICT_HOLIDAY_TYPES] = "SELECT h.rowid as rowid, h.entity, h.code, h.label, h.affect, h.delay, h.newbymonth, h.fk_country as country_id, c.code as country_code, c.label as country, h.block_if_negative, h.sortorder, h.active FROM ".MAIN_DB_PREFIX."c_holiday_types as h LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON h.fk_country=c.rowid WHERE h.entity IN (".getEntity($tabname[DICT_HOLIDAY_TYPES]).")";
319$tabsql[DICT_LEAD_STATUS] = "SELECT t.rowid as rowid, t.code, t.label, percent, t.position, t.active FROM ".MAIN_DB_PREFIX."c_lead_status as t";
320$tabsql[DICT_FORMAT_CARDS] = "SELECT t.rowid, t.code, t.name, t.paper_size, t.orientation, t.metric, t.leftmargin, t.topmargin, t.nx, t.ny, t.spacex, t.spacey, t.width, t.height, t.font_size, t.custom_x, t.custom_y, t.active FROM ".MAIN_DB_PREFIX."c_format_cards as t";
321$tabsql[DICT_INVOICE_SUBTYPE] = "SELECT t.rowid, t.code, t.label, c.label as country, c.code as country_code, t.fk_country as country_id, t.active FROM ".MAIN_DB_PREFIX."c_invoice_subtype as t, ".MAIN_DB_PREFIX."c_country as c WHERE t.fk_country = c.rowid";
322$tabsql[DICT_HRM_PUBLIC_HOLIDAY] = "SELECT a.id as rowid, a.entity, a.code, a.fk_country as country_id, c.code as country_code, c.label as country, a.dayrule, a.day, a.month, a.year, a.active FROM ".MAIN_DB_PREFIX."c_hrm_public_holiday as a LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON a.fk_country=c.rowid AND c.active=1 WHERE a.entity IN (".getEntity($tabname[DICT_HRM_PUBLIC_HOLIDAY]).")";
323$tabsql[DICT_HRM_DEPARTMENT] = "SELECT t.rowid, t.pos, t.code, t.label, t.active FROM ".MAIN_DB_PREFIX."c_hrm_department as t";
324$tabsql[DICT_HRM_FUNCTION] = "SELECT t.rowid, t.pos, t.code, t.label, t.c_level, t.active FROM ".MAIN_DB_PREFIX."c_hrm_function as t";
325$tabsql[DICT_EXP_TAX_CAT] = "SELECT c.rowid, c.label, c.active, c.entity FROM ".MAIN_DB_PREFIX."c_exp_tax_cat as c";
326$tabsql[DICT_EXP_TAX_RANGE] = "SELECT r.rowid, r.fk_c_exp_tax_cat, r.range_ik, r.active, r.entity FROM ".MAIN_DB_PREFIX."c_exp_tax_range r";
327$tabsql[DICT_UNITS] = "SELECT r.rowid, r.code, r.sortorder, r.label, r.short_label, r.unit_type, r.scale, r.active FROM ".MAIN_DB_PREFIX."c_units r";
328$tabsql[DICT_SOCIALNETWORKS] = "SELECT s.rowid, s.entity, s.code, s.label, s.url, s.icon, s.active FROM ".MAIN_DB_PREFIX."c_socialnetworks as s WHERE s.entity IN (".getEntity($tabname[DICT_SOCIALNETWORKS]).")";
329$tabsql[DICT_PROSPECTCONTACTLEVEL] = "SELECT t.code, t.label as libelle, t.sortorder, t.active FROM ".MAIN_DB_PREFIX."c_prospectcontactlevel as t";
330$tabsql[DICT_STCOMMCONTACT] = "SELECT t.id as rowid, t.code, t.libelle, t.picto, t.active FROM ".MAIN_DB_PREFIX."c_stcommcontact as t";
331$tabsql[DICT_TRANSPORT_MODE] = "SELECT t.rowid as rowid, t.code, t.label, t.active FROM ".MAIN_DB_PREFIX."c_transport_mode as t";
332$tabsql[DICT_PRODUCT_NATURE] = "SELECT t.rowid as rowid, t.code, t.label, t.active FROM ".MAIN_DB_PREFIX."c_product_nature as t";
333$tabsql[DICT_PRODUCTBATCH_QCSTATUS] = "SELECT t.rowid, t.code, t.label, t.active FROM ".MAIN_DB_PREFIX."c_productbatch_qcstatus as t";
334$tabsql[DICT_ASSET_DISPOSAL_TYPE] = "SELECT t.rowid, t.code, t.label, t.active FROM ".MAIN_DB_PREFIX."c_asset_disposal_type as t";
335
336// Criteria to sort dictionaries
337$tabsqlsort = array();
338$tabsqlsort[DICT_FORME_JURIDIQUE] = "country ASC, code ASC";
339$tabsqlsort[DICT_DEPARTEMENTS] = "country ASC, code ASC";
340$tabsqlsort[DICT_REGIONS] = "country ASC, code ASC";
341$tabsqlsort[DICT_COUNTRY] = "code ASC";
342$tabsqlsort[DICT_CIVILITY] = "label ASC";
343$tabsqlsort[DICT_ACTIONCOMM] = "a.type ASC, a.module ASC, a.position ASC, a.code ASC";
344$tabsqlsort[DICT_CHARGESOCIALES] = "c.label ASC, a.code ASC, a.libelle ASC";
345$tabsqlsort[DICT_TYPENT] = "country DESC,".(getDolGlobalString('SOCIETE_SORT_ON_TYPEENT') ? ' t.position ASC,' : '')." libelle ASC";
346$tabsqlsort[DICT_CURRENCIES] = "label ASC";
347$tabsqlsort[DICT_TVA] = "country ASC, department_buyer ASC, code ASC, taux ASC, recuperableonly ASC, localtax1 ASC, localtax2 ASC";
348$tabsqlsort[DICT_TYPE_CONTACT] = "t.element ASC, t.source ASC, t.position ASC, t.code ASC";
349$tabsqlsort[DICT_PAYMENT_TERM] = "sortorder ASC, code ASC";
350$tabsqlsort[DICT_PAIEMENT] = "code ASC";
351$tabsqlsort[DICT_ECOTAXE] = "country ASC, e.organization ASC, code ASC";
352$tabsqlsort[DICT_PAPER_FORMAT] = "rowid ASC";
353$tabsqlsort[DICT_PROSPECTLEVEL] = "sortorder ASC";
354$tabsqlsort[DICT_TYPE_FEES] = "code ASC";
355$tabsqlsort[DICT_SHIPMENT_MODE] = "code ASC, libelle ASC";
356$tabsqlsort[DICT_EFFECTIF] = "id ASC";
357$tabsqlsort[DICT_INPUT_METHOD] = "code ASC, libelle ASC";
358$tabsqlsort[DICT_AVAILABILITY] = "position ASC, type_duration ASC, qty ASC";
359$tabsqlsort[DICT_INPUT_REASON] = "code ASC, label ASC";
360$tabsqlsort[DICT_REVENUESTAMP] = "country ASC, taux ASC";
361$tabsqlsort[DICT_TYPE_RESOURCE] = "code ASC, label ASC";
362$tabsqlsort[DICT_TYPE_CONTAINER] = "t.module ASC, t.code ASC, t.label ASC";
363//$tabsqlsort[DICT_UNITS]="code ASC";
364$tabsqlsort[DICT_STCOMM] = "code ASC";
365$tabsqlsort[DICT_HOLIDAY_TYPES] = "sortorder ASC, country ASC, code ASC";
366$tabsqlsort[DICT_LEAD_STATUS] = "position ASC";
367$tabsqlsort[DICT_FORMAT_CARDS] = "code ASC";
368$tabsqlsort[DICT_INVOICE_SUBTYPE] = "country ASC, code ASC";
369$tabsqlsort[DICT_HRM_PUBLIC_HOLIDAY] = "country, year ASC, month ASC, day ASC";
370$tabsqlsort[DICT_HRM_DEPARTMENT] = "code ASC";
371$tabsqlsort[DICT_HRM_FUNCTION] = "code ASC";
372$tabsqlsort[DICT_EXP_TAX_CAT] = "c.label ASC";
373$tabsqlsort[DICT_EXP_TAX_RANGE] = "r.fk_c_exp_tax_cat ASC, r.range_ik ASC";
374$tabsqlsort[DICT_UNITS] = "sortorder ASC";
375$tabsqlsort[DICT_SOCIALNETWORKS] = "rowid, code ASC";
376$tabsqlsort[DICT_PROSPECTCONTACTLEVEL] = "sortorder ASC";
377$tabsqlsort[DICT_STCOMMCONTACT] = "code ASC";
378$tabsqlsort[DICT_TRANSPORT_MODE] = "code ASC";
379$tabsqlsort[DICT_PRODUCT_NATURE] = "code ASC";
380$tabsqlsort[DICT_PRODUCTBATCH_QCSTATUS] = "code ASC";
381$tabsqlsort[DICT_ASSET_DISPOSAL_TYPE] = "code ASC";
382
383// Field names in select result for dictionary display
384$tabfield = array();
385$tabfield[DICT_FORME_JURIDIQUE] = "code,libelle,country";
386$tabfield[DICT_DEPARTEMENTS] = "code,libelle,region_id,region,country"; // "code,libelle,region,country_code-country"
387$tabfield[DICT_REGIONS] = "code,libelle,country_id,country";
388$tabfield[DICT_COUNTRY] = "code,label,phone_code,trunk_prefix";
389$tabfield[DICT_CIVILITY] = "code,label";
390$tabfield[DICT_ACTIONCOMM] = "code,libelle,type,color,position";
391$tabfield[DICT_CHARGESOCIALES] = "code,libelle,country,accountancy_code,deductible";
392$tabfield[DICT_TYPENT] = "code,libelle,module,country_id,country".(getDolGlobalString('SOCIETE_SORT_ON_TYPEENT') ? ',position' : '');
393$tabfield[DICT_CURRENCIES] = "code,label,unicode";
394$tabfield[DICT_TVA] = "country_id,country,department_buyer_id,department_buyer,code,type_vat,taux,localtax1_type,localtax1,localtax2_type,localtax2,recuperableonly,einvoice_vatex,accountancy_code_sell,accountancy_code_buy,use_default,note";
395$tabfield[DICT_TYPE_CONTACT] = "element,source,code,libelle,position";
396$tabfield[DICT_PAYMENT_TERM] = "code,libelle,libelle_facture,deposit_percent,nbjour,type_cdr,decalage,sortorder";
397$tabfield[DICT_PAIEMENT] = "code,libelle,type,accountancy_code";
398$tabfield[DICT_ECOTAXE] = "code,label,price,organization,country";
399$tabfield[DICT_PAPER_FORMAT] = "code,libelle,width,height,unit";
400$tabfield[DICT_PROSPECTLEVEL] = "code,libelle,sortorder";
401$tabfield[DICT_TYPE_FEES] = "code,label,accountancy_code";
402$tabfield[DICT_SHIPMENT_MODE] = "code,libelle,tracking";
403$tabfield[DICT_EFFECTIF] = "code,libelle";
404$tabfield[DICT_INPUT_METHOD] = "code,libelle";
405$tabfield[DICT_AVAILABILITY] = "code,label,qty,type_duration,position";
406$tabfield[DICT_INPUT_REASON] = "code,label";
407$tabfield[DICT_REVENUESTAMP] = "country_id,country,taux,revenuestamp_type,accountancy_code_sell,accountancy_code_buy,note";
408$tabfield[DICT_TYPE_RESOURCE] = "code,label";
409$tabfield[DICT_TYPE_CONTAINER] = "code,label";
410//$tabfield[DICT_UNITS]= "code,label,short_label";
411$tabfield[DICT_STCOMM] = "code,libelle,picto";
412$tabfield[DICT_HOLIDAY_TYPES] = "code,label,affect,delay,newbymonth,country_id,country,block_if_negative,sortorder";
413$tabfield[DICT_LEAD_STATUS] = "code,label,percent,position";
414$tabfield[DICT_FORMAT_CARDS] = "code,name,paper_size,orientation,metric,leftmargin,topmargin,nx,ny,spacex,spacey,width,height,font_size,custom_x,custom_y";
415$tabfield[DICT_INVOICE_SUBTYPE] = "country_id,country,code,label";
416$tabfield[DICT_HRM_PUBLIC_HOLIDAY] = "code,dayrule,year,month,day,country_id,country";
417$tabfield[DICT_HRM_DEPARTMENT] = "code,label";
418$tabfield[DICT_HRM_FUNCTION] = "code,label";
419$tabfield[DICT_EXP_TAX_CAT] = "label";
420$tabfield[DICT_EXP_TAX_RANGE] = "range_ik,fk_c_exp_tax_cat";
421$tabfield[DICT_UNITS] = "code,label,short_label,unit_type,scale,sortorder";
422$tabfield[DICT_SOCIALNETWORKS] = "code,label,url,icon";
423$tabfield[DICT_PROSPECTCONTACTLEVEL] = "code,libelle,sortorder";
424$tabfield[DICT_STCOMMCONTACT] = "code,libelle,picto";
425$tabfield[DICT_TRANSPORT_MODE] = "code,label";
426$tabfield[DICT_PRODUCT_NATURE] = "code,label";
427$tabfield[DICT_PRODUCTBATCH_QCSTATUS] = "code,label";
428$tabfield[DICT_ASSET_DISPOSAL_TYPE] = "code,label";
429
430// Main fields to show by default into the list of each dictionary (subset of $tabfield, without the technical fields
431// entity, region_id, country_id and department_buyer_id that are never displayed).
432// All the other fields of $tabfield remain available: The user can choose to show or hide them with the selector
433// of columns (selection saved into setup of user for the key MAIN_SELECTEDFIELDS_dict<id>).
434// For dictionaries added by modules, there is no entry here, so all fields of $tabfield are shown by default.
435$tabfieldmain = array();
436$tabfieldmain[DICT_FORME_JURIDIQUE] = "code,libelle,country";
437$tabfieldmain[DICT_DEPARTEMENTS] = "code,libelle,region,country";
438$tabfieldmain[DICT_REGIONS] = "code,libelle,country";
439$tabfieldmain[DICT_COUNTRY] = "code,label,phone_code,trunk_prefix";
440$tabfieldmain[DICT_CIVILITY] = "code,label";
441$tabfieldmain[DICT_ACTIONCOMM] = "code,libelle,type,color,position";
442$tabfieldmain[DICT_CHARGESOCIALES] = "code,libelle,country,accountancy_code,deductible";
443$tabfieldmain[DICT_TYPENT] = "code,libelle,module,country".(getDolGlobalString('SOCIETE_SORT_ON_TYPEENT') ? ',position' : '');
444$tabfieldmain[DICT_CURRENCIES] = "code,label,unicode";
445$tabfieldmain[DICT_TVA] = "country,department_buyer,code,type_vat,taux,localtax1_type,localtax1,localtax2_type,localtax2,einvoice_vatex,accountancy_code_sell,accountancy_code_buy,use_default";
446$tabfieldmain[DICT_TYPE_CONTACT] = "element,source,code,libelle,position";
447$tabfieldmain[DICT_PAYMENT_TERM] = "code,libelle,libelle_facture,deposit_percent,nbjour,type_cdr,decalage,sortorder";
448$tabfieldmain[DICT_PAIEMENT] = "code,libelle,type,accountancy_code";
449$tabfieldmain[DICT_ECOTAXE] = "code,label,price,organization,country";
450$tabfieldmain[DICT_PAPER_FORMAT] = "code,libelle,width,height,unit";
451$tabfieldmain[DICT_PROSPECTLEVEL] = "code,libelle,sortorder";
452$tabfieldmain[DICT_TYPE_FEES] = "code,label,accountancy_code";
453$tabfieldmain[DICT_SHIPMENT_MODE] = "code,libelle,tracking";
454$tabfieldmain[DICT_EFFECTIF] = "code,libelle";
455$tabfieldmain[DICT_INPUT_METHOD] = "code,libelle";
456$tabfieldmain[DICT_AVAILABILITY] = "code,label,qty,type_duration,position";
457$tabfieldmain[DICT_INPUT_REASON] = "code,label";
458$tabfieldmain[DICT_REVENUESTAMP] = "country,taux,revenuestamp_type,accountancy_code_sell,accountancy_code_buy,note";
459$tabfieldmain[DICT_TYPE_RESOURCE] = "code,label";
460$tabfieldmain[DICT_TYPE_CONTAINER] = "code,label";
461$tabfieldmain[DICT_STCOMM] = "code,libelle,picto";
462$tabfieldmain[DICT_HOLIDAY_TYPES] = "code,label,affect,delay,newbymonth,country,block_if_negative,sortorder";
463$tabfieldmain[DICT_LEAD_STATUS] = "code,label,percent,position";
464$tabfieldmain[DICT_FORMAT_CARDS] = "code,name,paper_size,orientation,metric,leftmargin,topmargin,nx,ny,spacex,spacey,width,height,font_size,custom_x,custom_y";
465$tabfieldmain[DICT_INVOICE_SUBTYPE] = "country,code,label";
466$tabfieldmain[DICT_HRM_PUBLIC_HOLIDAY] = "code,dayrule,year,month,day,country";
467$tabfieldmain[DICT_HRM_DEPARTMENT] = "code,label";
468$tabfieldmain[DICT_HRM_FUNCTION] = "code,label";
469$tabfieldmain[DICT_EXP_TAX_CAT] = "label";
470$tabfieldmain[DICT_EXP_TAX_RANGE] = "range_ik,fk_c_exp_tax_cat";
471$tabfieldmain[DICT_UNITS] = "code,label,short_label,unit_type,scale,sortorder";
472$tabfieldmain[DICT_SOCIALNETWORKS] = "code,label,url,icon";
473$tabfieldmain[DICT_PROSPECTCONTACTLEVEL] = "code,libelle,sortorder";
474$tabfieldmain[DICT_STCOMMCONTACT] = "code,libelle,picto";
475$tabfieldmain[DICT_TRANSPORT_MODE] = "code,label";
476$tabfieldmain[DICT_PRODUCT_NATURE] = "code,label";
477$tabfieldmain[DICT_PRODUCTBATCH_QCSTATUS] = "code,label";
478$tabfieldmain[DICT_ASSET_DISPOSAL_TYPE] = "code,label";
479
480// Edit field names for editing a record
481$tabfieldvalue = array();
482$tabfieldvalue[DICT_FORME_JURIDIQUE] = "code,libelle,country";
483$tabfieldvalue[DICT_DEPARTEMENTS] = "code,libelle,region"; // "code,libelle,region"
484$tabfieldvalue[DICT_REGIONS] = "code,libelle,country";
485$tabfieldvalue[DICT_COUNTRY] = "code,label,phone_code,trunk_prefix";
486$tabfieldvalue[DICT_CIVILITY] = "code,label";
487$tabfieldvalue[DICT_ACTIONCOMM] = "code,libelle,type,color,position";
488$tabfieldvalue[DICT_CHARGESOCIALES] = "code,libelle,country,accountancy_code,deductible";
489$tabfieldvalue[DICT_TYPENT] = "code,libelle,country".(getDolGlobalString('SOCIETE_SORT_ON_TYPEENT') ? ',position' : '');
490$tabfieldvalue[DICT_CURRENCIES] = "code,label,unicode";
491$tabfieldvalue[DICT_TVA] = "country,department_buyer_id,code,type_vat,taux,localtax1_type,localtax1,localtax2_type,localtax2,recuperableonly,einvoice_vatex,accountancy_code_sell,accountancy_code_buy,use_default,note";
492$tabfieldvalue[DICT_TYPE_CONTACT] = "element,source,code,libelle,position";
493$tabfieldvalue[DICT_PAYMENT_TERM] = "code,libelle,libelle_facture,deposit_percent,nbjour,type_cdr,decalage,sortorder";
494$tabfieldvalue[DICT_PAIEMENT] = "code,libelle,type,accountancy_code";
495$tabfieldvalue[DICT_ECOTAXE] = "code,label,price,organization,country";
496$tabfieldvalue[DICT_PAPER_FORMAT] = "code,libelle,width,height,unit";
497$tabfieldvalue[DICT_PROSPECTLEVEL] = "code,libelle,sortorder";
498$tabfieldvalue[DICT_TYPE_FEES] = "code,label,accountancy_code";
499$tabfieldvalue[DICT_SHIPMENT_MODE] = "code,libelle,tracking";
500$tabfieldvalue[DICT_EFFECTIF] = "code,libelle";
501$tabfieldvalue[DICT_INPUT_METHOD] = "code,libelle";
502$tabfieldvalue[DICT_AVAILABILITY] = "code,label,qty,type_duration,position";
503$tabfieldvalue[DICT_INPUT_REASON] = "code,label";
504$tabfieldvalue[DICT_REVENUESTAMP] = "country,taux,revenuestamp_type,accountancy_code_sell,accountancy_code_buy,note";
505$tabfieldvalue[DICT_TYPE_RESOURCE] = "code,label";
506$tabfieldvalue[DICT_TYPE_CONTAINER] = "code,label";
507//$tabfieldvalue[DICT_UNITS]= "code,label,short_label";
508$tabfieldvalue[DICT_STCOMM] = "code,libelle,picto";
509$tabfieldvalue[DICT_HOLIDAY_TYPES] = "code,label,affect,delay,newbymonth,country,block_if_negative,sortorder";
510$tabfieldvalue[DICT_LEAD_STATUS] = "code,label,percent,position";
511$tabfieldvalue[DICT_FORMAT_CARDS] = "code,name,paper_size,orientation,metric,leftmargin,topmargin,nx,ny,spacex,spacey,width,height,font_size,custom_x,custom_y";
512$tabfieldvalue[DICT_INVOICE_SUBTYPE] = "country,code,label";
513$tabfieldvalue[DICT_HRM_PUBLIC_HOLIDAY] = "code,dayrule,day,month,year,country";
514$tabfieldvalue[DICT_HRM_DEPARTMENT] = "code,label";
515$tabfieldvalue[DICT_HRM_FUNCTION] = "code,label";
516$tabfieldvalue[DICT_EXP_TAX_CAT] = "label";
517$tabfieldvalue[DICT_EXP_TAX_RANGE] = "range_ik,fk_c_exp_tax_cat";
518$tabfieldvalue[DICT_UNITS] = "code,label,short_label,unit_type,scale,sortorder";
519$tabfieldvalue[DICT_SOCIALNETWORKS] = "code,label,url,icon";
520$tabfieldvalue[DICT_PROSPECTCONTACTLEVEL] = "code,libelle,sortorder";
521$tabfieldvalue[DICT_STCOMMCONTACT] = "code,libelle,picto";
522$tabfieldvalue[DICT_TRANSPORT_MODE] = "code,label";
523$tabfieldvalue[DICT_PRODUCT_NATURE] = "code,label";
524$tabfieldvalue[DICT_PRODUCTBATCH_QCSTATUS] = "code,label";
525$tabfieldvalue[DICT_ASSET_DISPOSAL_TYPE] = "code,label";
526
527// Field names in the table for inserting a record (add field "entity" only here when dictionary is ready to personalized by entity)
528$tabfieldinsert = array();
529$tabfieldinsert[DICT_FORME_JURIDIQUE] = "code,libelle,fk_pays";
530$tabfieldinsert[DICT_DEPARTEMENTS] = "code_departement,nom,fk_region";
531$tabfieldinsert[DICT_REGIONS] = "code_region,nom,fk_pays";
532$tabfieldinsert[DICT_COUNTRY] = "code,label,phone_code,trunk_prefix";
533$tabfieldinsert[DICT_CIVILITY] = "code,label";
534$tabfieldinsert[DICT_ACTIONCOMM] = "code,libelle,type,color,position";
535$tabfieldinsert[DICT_CHARGESOCIALES] = "code,libelle,fk_pays,accountancy_code,deductible";
536$tabfieldinsert[DICT_TYPENT] = "code,libelle,fk_country".(getDolGlobalString('SOCIETE_SORT_ON_TYPEENT') ? ',position' : '');
537$tabfieldinsert[DICT_CURRENCIES] = "code_iso,label,unicode";
538$tabfieldinsert[DICT_TVA] = "fk_pays,fk_department_buyer,code,type_vat,taux,localtax1_type,localtax1,localtax2_type,localtax2,recuperableonly,einvoice_vatex,accountancy_code_sell,accountancy_code_buy,use_default,note,entity";
539$tabfieldinsert[DICT_TYPE_CONTACT] = "element,source,code,libelle,position";
540$tabfieldinsert[DICT_PAYMENT_TERM] = "code,libelle,libelle_facture,deposit_percent,nbjour,type_cdr,decalage,sortorder,entity";
541$tabfieldinsert[DICT_PAIEMENT] = "code,libelle,type,accountancy_code,entity";
542$tabfieldinsert[DICT_ECOTAXE] = "code,label,price,organization,fk_pays";
543$tabfieldinsert[DICT_PAPER_FORMAT] = "code,label,width,height,unit";
544$tabfieldinsert[DICT_PROSPECTLEVEL] = "code,label,sortorder";
545$tabfieldinsert[DICT_TYPE_FEES] = "code,label,accountancy_code";
546$tabfieldinsert[DICT_SHIPMENT_MODE] = "code,libelle,tracking";
547$tabfieldinsert[DICT_EFFECTIF] = "code,libelle";
548$tabfieldinsert[DICT_INPUT_METHOD] = "code,libelle";
549$tabfieldinsert[DICT_AVAILABILITY] = "code,label,qty,type_duration,position";
550$tabfieldinsert[DICT_INPUT_REASON] = "code,label";
551$tabfieldinsert[DICT_REVENUESTAMP] = "fk_pays,taux,revenuestamp_type,accountancy_code_sell,accountancy_code_buy,note";
552$tabfieldinsert[DICT_TYPE_RESOURCE] = "code,label";
553$tabfieldinsert[DICT_TYPE_CONTAINER] = "code,label,entity";
554//$tabfieldinsert[DICT_UNITS]= "code,label,short_label";
555$tabfieldinsert[DICT_STCOMM] = "code,libelle,picto";
556$tabfieldinsert[DICT_HOLIDAY_TYPES] = "code,label,affect,delay,newbymonth,fk_country,block_if_negative,sortorder,entity";
557$tabfieldinsert[DICT_LEAD_STATUS] = "code,label,percent,position";
558$tabfieldinsert[DICT_FORMAT_CARDS] = "code,name,paper_size,orientation,metric,leftmargin,topmargin,nx,ny,spacex,spacey,width,height,font_size,custom_x,custom_y";
559$tabfieldinsert[DICT_INVOICE_SUBTYPE] = "fk_country,code,label";
560$tabfieldinsert[DICT_HRM_PUBLIC_HOLIDAY] = "code,dayrule,day,month,year,fk_country,entity";
561$tabfieldinsert[DICT_HRM_DEPARTMENT] = "code,label";
562$tabfieldinsert[DICT_HRM_FUNCTION] = "code,label";
563$tabfieldinsert[DICT_EXP_TAX_CAT] = "label";
564$tabfieldinsert[DICT_EXP_TAX_RANGE] = "range_ik,fk_c_exp_tax_cat";
565$tabfieldinsert[DICT_UNITS] = "code,label,short_label,unit_type,scale,sortorder";
566$tabfieldinsert[DICT_SOCIALNETWORKS] = "code,label,url,icon,entity";
567$tabfieldinsert[DICT_PROSPECTCONTACTLEVEL] = "code,label,sortorder";
568$tabfieldinsert[DICT_STCOMMCONTACT] = "code,libelle,picto";
569$tabfieldinsert[DICT_TRANSPORT_MODE] = "code,label";
570$tabfieldinsert[DICT_PRODUCT_NATURE] = "code,label";
571$tabfieldinsert[DICT_PRODUCTBATCH_QCSTATUS] = "code,label";
572$tabfieldinsert[DICT_ASSET_DISPOSAL_TYPE] = "code,label";
573
574// Rowid name of field depending if field is autoincrement on or off..
575// Use "" if id field is "rowid" and has autoincrement on
576// Use "nameoffield" if id field is not "rowid" or has not autoincrement on
577$tabrowid = array();
578$tabrowid[DICT_FORME_JURIDIQUE] = "";
579$tabrowid[DICT_DEPARTEMENTS] = "";
580$tabrowid[DICT_REGIONS] = "";
581$tabrowid[DICT_COUNTRY] = "rowid";
582$tabrowid[DICT_CIVILITY] = "rowid";
583$tabrowid[DICT_ACTIONCOMM] = "id";
584$tabrowid[DICT_CHARGESOCIALES] = "id";
585$tabrowid[DICT_TYPENT] = "id";
586$tabrowid[DICT_CURRENCIES] = "code_iso";
587$tabrowid[DICT_TVA] = "";
588$tabrowid[DICT_TYPE_CONTACT] = "rowid";
589$tabrowid[DICT_PAYMENT_TERM] = "";
590$tabrowid[DICT_PAIEMENT] = "id";
591$tabrowid[DICT_ECOTAXE] = "";
592$tabrowid[DICT_PAPER_FORMAT] = "";
593$tabrowid[DICT_PROSPECTLEVEL] = "code";
594$tabrowid[DICT_TYPE_FEES] = "id";
595$tabrowid[DICT_SHIPMENT_MODE] = "rowid";
596$tabrowid[DICT_EFFECTIF] = "id";
597$tabrowid[DICT_INPUT_METHOD] = "";
598$tabrowid[DICT_AVAILABILITY] = "rowid";
599$tabrowid[DICT_INPUT_REASON] = "rowid";
600$tabrowid[DICT_REVENUESTAMP] = "";
601$tabrowid[DICT_TYPE_RESOURCE] = "";
602$tabrowid[DICT_TYPE_CONTAINER] = "";
603//$tabrowid[DICT_UNITS]= "";
604$tabrowid[DICT_STCOMM] = "id";
605$tabrowid[DICT_HOLIDAY_TYPES] = "";
606$tabrowid[DICT_LEAD_STATUS] = "";
607$tabrowid[DICT_FORMAT_CARDS] = "";
608$tabrowid[DICT_INVOICE_SUBTYPE] = "";
609$tabrowid[DICT_HRM_PUBLIC_HOLIDAY] = "id";
610$tabrowid[DICT_HRM_DEPARTMENT] = "rowid";
611$tabrowid[DICT_HRM_FUNCTION] = "rowid";
612$tabrowid[DICT_EXP_TAX_CAT] = "";
613$tabrowid[DICT_EXP_TAX_RANGE] = "";
614$tabrowid[DICT_UNITS] = "";
615$tabrowid[DICT_SOCIALNETWORKS] = "";
616$tabrowid[DICT_PROSPECTCONTACTLEVEL] = "code";
617$tabrowid[DICT_STCOMMCONTACT] = "id";
618$tabrowid[DICT_TRANSPORT_MODE] = "";
619$tabrowid[DICT_PRODUCT_NATURE] = "rowid";
620$tabrowid[DICT_PRODUCTBATCH_QCSTATUS] = "rowid";
621$tabrowid[DICT_ASSET_DISPOSAL_TYPE] = "rowid";
622
623// Condition to show dictionary in setup page
624$tabcond = array();
625$tabcond[DICT_FORME_JURIDIQUE] = (isModEnabled("societe"));
626$tabcond[DICT_DEPARTEMENTS] = true;
627$tabcond[DICT_REGIONS] = true;
628$tabcond[DICT_COUNTRY] = true;
629$tabcond[DICT_CIVILITY] = (isModEnabled("societe") || isModEnabled('member'));
630$tabcond[DICT_ACTIONCOMM] = isModEnabled('agenda');
631$tabcond[DICT_CHARGESOCIALES] = isModEnabled('tax');
632$tabcond[DICT_TYPENT] = isModEnabled("societe");
633$tabcond[DICT_CURRENCIES] = true;
634$tabcond[DICT_TVA] = true;
635$tabcond[DICT_TYPE_CONTACT] = (isModEnabled("societe"));
636$tabcond[DICT_PAYMENT_TERM] = (isModEnabled('order') || isModEnabled("propal") || isModEnabled('invoice') || isModEnabled("supplier_invoice") || isModEnabled("supplier_order"));
637$tabcond[DICT_PAIEMENT] = (isModEnabled('order') || isModEnabled("propal") || isModEnabled('invoice') || isModEnabled("supplier_invoice") || isModEnabled("supplier_order"));
638$tabcond[DICT_ECOTAXE] = (isModEnabled("product") && (isModEnabled('ecotax') || getDolGlobalString('MAIN_SHOW_ECOTAX_DICTIONNARY')));
639$tabcond[DICT_PAPER_FORMAT] = true;
640$tabcond[DICT_PROSPECTLEVEL] = (isModEnabled("societe") && !getDolGlobalString('SOCIETE_DISABLE_PROSPECTS'));
641$tabcond[DICT_TYPE_FEES] = (isModEnabled('deplacement') || isModEnabled('expensereport'));
642$tabcond[DICT_SHIPMENT_MODE] = isModEnabled("shipping") || isModEnabled("reception");
643$tabcond[DICT_EFFECTIF] = isModEnabled("societe");
644$tabcond[DICT_INPUT_METHOD] = isModEnabled("supplier_order");
645$tabcond[DICT_AVAILABILITY] = isModEnabled("propal");
646$tabcond[DICT_INPUT_REASON] = (isModEnabled('order') || isModEnabled("propal"));
647$tabcond[DICT_REVENUESTAMP] = true;
648$tabcond[DICT_TYPE_RESOURCE] = isModEnabled('resource');
649$tabcond[DICT_TYPE_CONTAINER] = isModEnabled('website');
650//$tabcond[DICT_UNITS]= isModEnabled("product");
651$tabcond[DICT_STCOMM] = isModEnabled("societe");
652$tabcond[DICT_HOLIDAY_TYPES] = isModEnabled('holiday');
653$tabcond[DICT_LEAD_STATUS] = isModEnabled('project');
654$tabcond[DICT_FORMAT_CARDS] = (isModEnabled('label') || isModEnabled('barcode') || isModEnabled('member')); // stickers format dictionary
655$tabcond[DICT_INVOICE_SUBTYPE] = ((isModEnabled('invoice') || isModEnabled('supplier_invoice')) && $mysoc->country_code == 'GR');
656$tabcond[DICT_HRM_PUBLIC_HOLIDAY] = (isModEnabled('holiday') || isModEnabled('hrm'));
657$tabcond[DICT_HRM_DEPARTMENT] = isModEnabled('hrm');
658$tabcond[DICT_HRM_FUNCTION] = isModEnabled('hrm');
659$tabcond[DICT_EXP_TAX_CAT] = isModEnabled('expensereport') && getDolGlobalString('MAIN_USE_EXPENSE_IK');
660$tabcond[DICT_EXP_TAX_RANGE] = isModEnabled('expensereport') && getDolGlobalString('MAIN_USE_EXPENSE_IK');
661$tabcond[DICT_UNITS] = isModEnabled("product");
662$tabcond[DICT_SOCIALNETWORKS] = isModEnabled('socialnetworks');
663$tabcond[DICT_PROSPECTCONTACTLEVEL] = (isModEnabled("societe") && !getDolGlobalString('SOCIETE_DISABLE_PROSPECTS') && getDolGlobalString('THIRDPARTY_ENABLE_PROSPECTION_ON_ALTERNATIVE_ADRESSES'));
664$tabcond[DICT_STCOMMCONTACT] = (isModEnabled("societe") && getDolGlobalString('THIRDPARTY_ENABLE_PROSPECTION_ON_ALTERNATIVE_ADRESSES'));
665$tabcond[DICT_TRANSPORT_MODE] = isModEnabled('intracommreport');
666$tabcond[DICT_PRODUCT_NATURE] = isModEnabled("product");
667$tabcond[DICT_PRODUCTBATCH_QCSTATUS] = isModEnabled("product") && isModEnabled('productbatch') && getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2;
668$tabcond[DICT_ASSET_DISPOSAL_TYPE] = isModEnabled('asset');
669
670// List of help for fields (no more used, help is defined into tabcomplete)
671$tabhelp = array();
672
673
674$tooltipvatex = $langs->trans("VATExemptionCodeDesc").'<br>'.$langs->trans("VATExemptionCodeDesc2").'<br>'.$langs->trans("VATExemptionCodeDesc3");
675if (($mysoc->country_code == 'FR')) {
676 $tooltipvatex .= '<br><br>'.$langs->trans("Example").':<br>';
677 $tooltipvatex .= 'VATEX-FR-FRANCHISE, VATEX-FR-CGI261-4, VATEX-FR-J, VATEX-FR-I, VATEX-FR-D, ...';
678}
679
680// Table to store complete information (will replace all other tables). Key is table name.
681$tabcomplete = array(
682 'c_forme_juridique' => array(
683 'picto' => 'company',
684 'help' => array('code' => $langs->trans("EnterAnyCode"))
685 ),
686 'c_departements' => array(
687 'picto' => 'state',
688 'help' => array('code' => $langs->trans("EnterAnyCode"))
689 ),
690 'c_regions' => array(
691 'picto' => 'region',
692 'help' => array('code' => $langs->trans("EnterAnyCode"))
693 ),
694 'c_country' => array('picto' => 'country', 'help' => array('code' => $langs->trans("EnterAnyCode"), 'phone_code' => 'e.g. 33', 'trunk_prefix' => 'e.g. 0')),
695 'c_civility' => array('picto' => 'contact', 'help' => array('code' => $langs->trans("EnterAnyCode"))),
696 'c_actioncomm' => array('picto' => 'action', 'help' => array('code' => $langs->trans("EnterAnyCode"), 'color' => $langs->trans("ColorFormat"), 'position' => $langs->trans("PositionIntoComboList"))),
697 'c_chargesociales' => array('picto' => 'bill', 'help' => array('code' => $langs->trans("EnterAnyCode"))),
698 'c_typent' => array('picto' => 'company', 'help' => array('code' => $langs->trans("EnterAnyCode"), 'position' => $langs->trans("PositionIntoComboList"))),
699 'c_currencies' => array('picto' => 'multicurrency', 'help' => array('code' => $langs->trans("EnterAnyCode"), 'unicode' => $langs->trans("UnicodeCurrency"))),
700 'c_tva' => array('picto' => 'bill', 'css' => array('einvoice_vatex' => 'tdoverflowmax100'), 'help' => array('code' => $langs->trans("EnterAnyCode"), 'taux' => $langs->trans("SellTaxRate"), 'recuperableonly' => $langs->trans("RecuperableOnly"), 'localtax1_type' => $langs->trans("LocalTaxDesc"), 'localtax2_type' => $langs->trans("LocalTaxDesc"), 'einvoice_vatex' => $tooltipvatex)),
701 'c_type_contact' => array('picto' => 'contact', 'help' => array('code' => $langs->trans("EnterAnyCode"), 'position' => $langs->trans("PositionIntoComboList"))),
702 'c_payment_term' => array('picto' => 'bill', 'help' => array('code' => $langs->trans("EnterAnyCode"), 'type_cdr' => $langs->trans("TypeCdr", $langs->transnoentitiesnoconv("NbOfDays"), $langs->transnoentitiesnoconv("Offset"), $langs->transnoentitiesnoconv("NbOfDays"), $langs->transnoentitiesnoconv("Offset")))),
703 'c_paiement' => array('picto' => 'bill', 'help' => array('code' => $langs->trans("EnterAnyCode"))),
704 'c_ecotaxe' => array('picto' => 'bill', 'help' => array('code' => $langs->trans("EnterAnyCode"))),
705 'c_paper_format' => array('picto' => 'generic', 'help' => array('code' => $langs->trans("EnterAnyCode"))),
706 'c_prospectlevel' => array('picto' => 'company', 'help' => array('code' => $langs->trans("EnterAnyCode"))),
707 'c_type_fees' => array('picto' => 'trip', 'help' => array('code' => $langs->trans("EnterAnyCode"))),
708 'c_shipment_mode' => array('picto' => 'shipment', 'help' => array('code' => $langs->trans("EnterAnyCode"), 'tracking' => $langs->trans("UrlTrackingDesc"))),
709 'c_effectif' => array('picto' => 'company', 'help' => array('code' => $langs->trans("EnterAnyCode"))),
710 'c_input_method' => array('picto' => 'order', 'help' => array('code' => $langs->trans("EnterAnyCode"))),
711 'c_input_reason' => array('picto' => 'order', 'help' => array('code' => $langs->trans("EnterAnyCode"), 'position' => $langs->trans("PositionIntoComboList"))),
712 'c_availability' => array('picto' => 'shipment', 'help' => array('code' => $langs->trans("EnterAnyCode"))),
713 'c_revenuestamp' => array('picto' => 'bill', 'help' => array('revenuestamp_type' => $langs->trans('FixedOrPercent'))),
714 'c_type_resource' => array('picto' => 'resource', 'help' => array('code' => $langs->trans("EnterAnyCode"))),
715 'c_type_container' => array('picto' => 'website', 'help' => array('code' => $langs->trans("EnterAnyCode"))),
716 'c_stcomm' => array('picto' => 'company', 'help' => array('code' => $langs->trans("EnterAnyCode"), 'picto' => $langs->trans("PictoHelp"))),
717 'c_holiday_types' => array('picto' => 'holiday', 'help' => array('affect' => $langs->trans("FollowedByACounter"), 'delay' => $langs->trans("MinimumNoticePeriod"), 'newbymonth' => $langs->trans("NbAddedAutomatically"))),
718 'c_lead_status' => array('picto' => 'project', 'help' => array('code' => $langs->trans("EnterAnyCode"), 'percent' => $langs->trans("OpportunityPercent"), 'position' => $langs->trans("PositionIntoComboList"))),
719 'c_format_cards' => array('picto' => 'generic', 'help' => array('code' => $langs->trans("EnterAnyCode"), 'name' => $langs->trans("LabelName"), 'paper_size' => $langs->trans("LabelPaperSize"))),
720 'c_hrm_public_holiday' => array('picto' => 'holiday', 'help' => array('code' => $langs->trans("EnterAnyCode"), 'dayrule' => "Keep empty for a date defined with month and day (most common case).<br>Use a keyword like 'easter', 'eastermonday', ... for a date predefined by complex rules.", 'country' => $langs->trans("CountryIfSpecificToOneCountry"), 'year' => $langs->trans("ZeroMeansEveryYear"))),
721 'c_hrm_department' => array('picto' => 'hrm', 'help' => array('code' => $langs->trans("EnterAnyCode"))),
722 'c_hrm_function' => array('picto' => 'hrm', 'help' => array('code' => $langs->trans("EnterAnyCode"))),
723 'c_exp_tax_cat' => array('picto' => 'expensereport', 'help' => array()),
724 'c_exp_tax_range' => array('picto' => 'expensereport', 'help' => array('range_ik' => $langs->trans('PrevRangeToThisRange'))),
725 'c_units' => array('picto' => 'product', 'help' => array('code' => $langs->trans("EnterAnyCode"), 'unit_type' => $langs->trans('Measuringtype_durationDesc'), 'scale' => $langs->trans('MeasuringScaleDesc'))),
726 'c_socialnetworks' => array('picto' => 'share-alt', 'help' => array('code' => $langs->trans("EnterAnyCode"), 'url' => $langs->trans('UrlSocialNetworksDesc'), 'icon' => $langs->trans('FafaIconSocialNetworksDesc'))),
727 'c_prospectcontactlevel' => array('picto' => 'company', 'help' => array('code' => $langs->trans("EnterAnyCode"))),
728 'c_stcommcontact' => array('picto' => 'company', 'help' => array('code' => $langs->trans("EnterAnyCode"), 'picto' => $langs->trans("PictoHelp"))),
729 'c_transport_mode' => array('picto' => 'incoterm', 'help' => array('code' => $langs->trans("EnterAnyCode"))),
730 'c_product_nature' => array('picto' => 'product', 'help' => array('code' => $langs->trans("EnterAnyCode"))),
731 'c_productbatch_qcstatus' => array('picto' => 'lot', 'help' => array('code' => $langs->trans("EnterAnyCode"))),
732 'c_asset_disposal_type' => array('picto' => 'asset', 'help' => array('code' => $langs->trans("EnterAnyCode"))),
733 'c_invoice_subtype' => array('picto' => 'bill', 'help' => array('code' => $langs->trans("EnterAnyCode"))),
734);
735
736
737// Complete all arrays with entries found into modules
738complete_dictionary_with_modules($taborder, $tabname, $tablib, $tabsql, $tabsqlsort, $tabfield, $tabfieldvalue, $tabfieldinsert, $tabrowid, $tabcond, $tabhelp, $tabcomplete);
739
740// Complete the table $tabcomplete
741$i = 0;
742foreach ($tabcomplete as $key => $value) {
743 $i++;
744 // When a dictionary is commented
745 if (!isset($tabcond[$i])) {
746 continue;
747 }
748 $tabcomplete[$key]['id'] = $i;
749
750 // TODO Comment this lines when data is stored into the tabcomplete array
751 $tabcomplete[$key]['cond'] = $tabcond[$i];
752 $tabcomplete[$key]['rowid'] = $tabrowid[$i];
753 $tabcomplete[$key]['fieldinsert'] = $tabfieldinsert[$i];
754 $tabcomplete[$key]['fieldvalue'] = $tabfieldvalue[$i];
755 $tabcomplete[$key]['lib'] = $tablib[$i];
756 $tabcomplete[$key]['sql'] = $tabsql[$i];
757 $tabcomplete[$key]['sqlsort'] = $tabsqlsort[$i];
758 $tabcomplete[$key]['field'] = $tabfield[$i];
759 //$tabcomplete[$key]['picto'] = $tabpicto[$i]; // array picto already loaded into tabcomplete
760 //$tabcomplete[$key]['help'] = $tabhelp[$i]; // array help already loaded into tabcomplete
761}
762
763$keytable = '';
764if ($id > 0) {
765 $arrayofkeys = array_keys($tabcomplete);
766 if (array_key_exists($id - 1, $arrayofkeys)) {
767 $keytable = $arrayofkeys[$id - 1];
768 }
769}
770
771// Default sortorder
772if (empty($sortfield)) {
773 $tmp1 = explode(',', empty($tabcomplete[$keytable]['sqlsort']) ? '' : $tabcomplete[$keytable]['sqlsort']);
774 $tmp2 = explode(' ', $tmp1[0]);
775 $sortfield = preg_replace('/^.*\./', '', $tmp2[0]);
776 $sortorder = (!empty($tmp2[1]) ? $tmp2[1] : ''); // @phan-suppress-current-line SqlInjection
777 //var_dump($sortfield); //var_dump($sortorder);
778}
779
780global $elementList, $sourceList, $localtax_typeList, $type_vatList; // Used in dictFieldList() below
781
782// Define elementList and sourceList (used for dictionary type of contacts "llx_c_type_contact")
783$elementList = array();
784$sourceList = array();
785if ($id == DICT_TYPE_CONTACT) {
786 $elementList = array(
787 '' => '',
788 'agenda' => img_picto('', 'action', 'class="pictofixedwidth"').$langs->trans('Agenda'),
789 'dolresource' => img_picto('', 'resource', 'class="pictofixedwidth"').$langs->trans('Resource'),
790 'societe' => img_picto('', 'company', 'class="pictofixedwidth"').$langs->trans('ThirdParty'),
791 'product' => img_picto('', 'product', 'class="pictofixedwidth"').$langs->trans('Product'),
792 // 'proposal' => $langs->trans('Proposal'),
793 // 'order' => $langs->trans('Order'),
794 // 'invoice' => $langs->trans('Bill'),
795 // 'intervention' => $langs->trans('InterventionCard'),
796 // 'contract' => $langs->trans('Contract'),
797 'project' => img_picto('', 'project', 'class="pictofixedwidth"').$langs->trans('Project'),
798 'project_task' => img_picto('', 'projecttask', 'class="pictofixedwidth"').$langs->trans('Task'),
799 'propal' => img_picto('', 'propal', 'class="pictofixedwidth"').$langs->trans('Proposal'),
800 'commande' => img_picto('', 'order', 'class="pictofixedwidth"').$langs->trans('Order'),
801 'shipping' => img_picto('', 'dolly', 'class="pictofixedwidth"') . $langs->trans('Shipment'),
802 'facture' => img_picto('', 'bill', 'class="pictofixedwidth"').$langs->trans('Bill'),
803 'fichinter' => img_picto('', 'intervention', 'class="pictofixedwidth"').$langs->trans('InterventionCard'),
804 'contrat' => img_picto('', 'contract', 'class="pictofixedwidth"').$langs->trans('Contract'),
805 'ticket' => img_picto('', 'ticket', 'class="pictofixedwidth"').$langs->trans('Ticket'),
806 'supplier_proposal' => img_picto('', 'supplier_proposal', 'class="pictofixedwidth"').$langs->trans('SupplierProposal'),
807 'order_supplier' => img_picto('', 'supplier_order', 'class="pictofixedwidth"').$langs->trans('SupplierOrder'),
808 'invoice_supplier' => img_picto('', 'supplier_invoice', 'class="pictofixedwidth"').$langs->trans('SupplierBill'),
809 'conferenceorbooth' => img_picto('', 'eventorganization', 'class="pictofixedwidth"').$langs->trans('ConferenceOrBooth'),
810 );
811
812 complete_elementList_with_modules($elementList);
813
814 //asort($elementList);
815 $sourceList = array(
816 'internal' => $langs->trans('Internal'),
817 'external' => $langs->trans('External')
818 );
819}
820
821// Define type_vatList (used for dictionary "llx_c_tva")
822$type_vatList = array(
823 "0" => $langs->trans("Sell").'+'.$langs->trans("Buy"),
824 "1" => $langs->trans("Sell"),
825 "2" => $langs->trans("Buy")
826);
827
828// Define localtax_typeList (used for dictionary "llx_c_tva")
829$localtax_typeList = array(
830 "0" => $langs->trans("No"),
831 "1" => $langs->trans("Yes").' ('.$langs->trans("Type")." 1)", //$langs->trans("%ageOnAllWithoutVAT"),
832 "2" => $langs->trans("Yes").' ('.$langs->trans("Type")." 2)", //$langs->trans("%ageOnAllBeforeVAT"),
833 "3" => $langs->trans("Yes").' ('.$langs->trans("Type")." 3)", //$langs->trans("%ageOnProductsWithoutVAT"),
834 "4" => $langs->trans("Yes").' ('.$langs->trans("Type")." 4)", //$langs->trans("%ageOnProductsBeforeVAT"),
835 "5" => $langs->trans("Yes").' ('.$langs->trans("Type")." 5)", //$langs->trans("%ageOnServiceWithoutVAT"),
836 "6" => $langs->trans("Yes").' ('.$langs->trans("Type")." 6)" //$langs->trans("%ageOnServiceBeforeVAT"),
837);
838
839
840
841/*
842 * Actions
843 */
844
845$object = new stdClass();
846$parameters = array(
847 'id' => $id,
848 'rowid' => $rowid,
849 'code' => $code,
850 'confirm' => $confirm,
851 'entity' => $entity,
852 'taborder' => $taborder,
853 'tabname' => $tabname,
854 'tablib' => $tablib,
855 'tabsql' => $tabsql,
856 'tabsqlsort' => $tabsqlsort,
857 'tabfield' => $tabfield,
858 'tabfieldvalue' => $tabfieldvalue,
859 'tabfieldinsert' => $tabfieldinsert,
860 'tabrowid' => $tabrowid,
861 'tabcond' => $tabcond,
862 'tabhelp' => $tabhelp,
863 'tabcomplete' => $tabcomplete
864);
865$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
866if ($reshook < 0) {
867 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
868}
869
870if (GETPOST('button_removefilter', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter_x', 'alpha')) {
871 $search_country_id = '';
872 $search_code = '';
873 $search_active = '';
874}
875
876if (empty($reshook)) {
877 // Change selection of columns to show into list (save the selection into user setup)
878 include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
879
880 // Actions add or modify an entry into a dictionary
881 if (GETPOST('actionadd') || GETPOST('actionmodify')) {
882 $listfield = explode(',', str_replace(' ', '', $tabfield[$id]));
883 $listfieldinsert = explode(',', $tabfieldinsert[$id]);
884 $listfieldmodify = explode(',', $tabfieldinsert[$id]);
885 $listfieldvalue = explode(',', $tabfieldvalue[$id]);
886
887 // Check that all mandatory fields are filled
888 $ok = 1;
889 foreach ($listfield as $f => $value) {
890 // Discard check of mandatory fields for country for some tables
891 if ($value == 'country_id' && in_array($tablib[$id], array('DictionaryPublicHolidays', 'DictionaryVAT', 'DictionaryInvoiceSubtype', 'DictionaryRegion', 'DictionaryCompanyType', 'DictionaryHolidayTypes', 'DictionaryRevenueStamp', 'DictionaryAccountancysystem', 'DictionaryAccountancyCategory'))) {
892 continue; // For some pages, country is not mandatory
893 }
894 if ($value == 'country' && in_array($tablib[$id], array('DictionaryPublicHolidays', 'DictionaryCanton', 'DictionaryCompanyType', 'DictionaryHolidayTypes', 'DictionaryRevenueStamp'))) {
895 continue; // For some pages, country is not mandatory
896 }
897 // Discard check of mandatory fields for department buyer id for some tables (only for add action)
898 if (GETPOST('actionadd') && $value == 'department_buyer_id' && $tablib[$id] == 'DictionaryVAT') {
899 continue; // For some pages, department buyer id is not mandatory
900 }
901 // Discard check of mandatory fields for department buyer for some tables
902 if ($value == 'department_buyer' && $tablib[$id] == 'DictionaryVAT') {
903 continue; // For some pages, department buyer is not mandatory
904 }
905 // Discard check of mandatory fields for other fields
906 $notmandatoryarray = array('localtax1', 'localtax2', 'color', 'formula', 'dayrule', 'einvoice_vatex', 'phone_code', 'trunk_prefix');
907 foreach ($notmandatoryarray as $notmandatory) {
908 if ($value == $notmandatory && !GETPOST($notmandatory)) {
909 continue 2;
910 }
911 }
912 if ($value == 'sortorder') {
913 continue; // For a column name 'sortorder', we use the field name 'position'
914 }
915 if ((!GETPOSTISSET($value) || GETPOST($value) == '')
916 && (
917 !in_array($value, array('decalage', 'module', 'accountancy_code', 'accountancy_code_sell', 'accountancy_code_buy', 'tracking', 'picto', 'deposit_percent')) // Fields that are not mandatory
918 && ($id != DICT_TVA || ($value != 'code' && $value != 'note')) // Field code and note is not mandatory for dictionary table 10
919 )
920 ) {
921 $ok = 0;
922 $fieldnamekey = $value;
923 // We take translate key of field
924 if ($fieldnamekey == 'libelle' || ($fieldnamekey == 'label')) {
925 $fieldnamekey = 'Label';
926 }
927 if ($fieldnamekey == 'libelle_facture') {
928 $fieldnamekey = 'LabelOnDocuments';
929 }
930 if ($fieldnamekey == 'deposit_percent') {
931 $fieldnamekey = 'DepositPercent';
932 }
933 if ($fieldnamekey == 'nbjour') {
934 $fieldnamekey = 'NbOfDays';
935 }
936 if ($fieldnamekey == 'decalage') {
937 $fieldnamekey = 'Offset';
938 }
939 if ($fieldnamekey == 'module') {
940 $fieldnamekey = 'Module';
941 }
942 if ($fieldnamekey == 'code') {
943 $fieldnamekey = 'Code';
944 }
945 if ($fieldnamekey == 'note') {
946 $fieldnamekey = 'Note';
947 }
948 if ($fieldnamekey == 'taux') {
949 $fieldnamekey = 'Rate';
950 }
951 if ($fieldnamekey == 'type') {
952 $fieldnamekey = 'Type';
953 }
954 if ($fieldnamekey == 'position') {
955 $fieldnamekey = 'Position';
956 }
957 if ($fieldnamekey == 'unicode') {
958 $fieldnamekey = 'Unicode';
959 }
960 if ($fieldnamekey == 'deductible') {
961 $fieldnamekey = 'Deductible';
962 }
963 if ($fieldnamekey == 'sortorder') {
964 $fieldnamekey = 'SortOrder';
965 }
966 if ($fieldnamekey == 'category_type') {
967 $fieldnamekey = 'Calculated';
968 }
969 if ($fieldnamekey == 'revenuestamp_type') {
970 $fieldnamekey = 'TypeOfRevenueStamp';
971 }
972 if ($fieldnamekey == 'use_default') {
973 $fieldnamekey = 'UseByDefault';
974 }
975
976 setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentities($fieldnamekey)), null, 'errors');
977 }
978 }
979 // Other special checks
980 if (GETPOST('actionadd') && $tabname[$id] == "c_actioncomm" && GETPOSTISSET("type") && in_array(GETPOST("type"), array('system', 'systemauto'))) {
981 $ok = 0;
982 setEventMessages($langs->transnoentities('ErrorReservedTypeSystemSystemAuto'), null, 'errors');
983 }
984 if (GETPOSTISSET("code")) {
985 if (GETPOST("code") == '0') {
986 $ok = 0;
987 setEventMessages($langs->transnoentities('ErrorCodeCantContainZero'), null, 'errors');
988 }
989 }
990 if (GETPOSTISSET("country") && (GETPOST("country") == '0') && ($id != DICT_DEPARTEMENTS)) {
991 if (in_array($tablib[$id], array('DictionaryCompanyType', 'DictionaryHolidayTypes'))) { // Field country is no mandatory for such dictionaries
992 $_POST["country"] = '';
993 } else {
994 $ok = 0;
995 setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentities("Country")), null, 'errors');
996 }
997 }
998 if (($id == DICT_REGIONS || $id == DICT_PRODUCT_NATURE) && !is_numeric(GETPOST("code")) && GETPOST('actionadd')) {
999 $ok = 0;
1000 $langs->load('errors');
1001 setEventMessages($langs->transnoentities("ErrorFieldMustBeANumeric", $langs->transnoentities("Code")), null, 'errors');
1002 }
1003 if ($id == DICT_COUNTRY && strlen(GETPOST("code")) != 2) { // 2 char on code for country code
1004 $ok = 0;
1005 $langs->load('errors');
1006 setEventMessages($langs->transnoentities("ErrorCountryCodeMustBe2Char", $langs->transnoentities("Code")), null, 'errors');
1007 }
1008 if ($id == DICT_PAIEMENT && strlen(GETPOST("code")) >= 6) { // 6 char max on code for payment mode codes
1009 $ok = 0;
1010 $langs->load('errors');
1011 setEventMessages($langs->transnoentities("ErrorFieldMustHaveLessThanXChar", $langs->transnoentities("Code"), '6'), null, 'errors');
1012 }
1013
1014 // Clean some parameters
1015 if ((GETPOST("localtax1_type") || (GETPOST('localtax1_type') == '0')) && !GETPOST("localtax1")) {
1016 $_POST["localtax1"] = '0'; // If empty, we force to 0
1017 }
1018 if ((GETPOST("localtax2_type") || (GETPOST('localtax2_type') == '0')) && !GETPOST("localtax2")) {
1019 $_POST["localtax2"] = '0'; // If empty, we force to 0
1020 }
1021 if (GETPOST('department_buyer_id') <= 0) {
1022 $_POST['department_buyer_id'] = ''; // If empty, we force to null
1023 }
1024 if (GETPOST("accountancy_code") <= 0) {
1025 $_POST["accountancy_code"] = ''; // If empty, we force to null
1026 }
1027 if (GETPOST("accountancy_code_sell") <= 0) {
1028 $_POST["accountancy_code_sell"] = ''; // If empty, we force to null
1029 }
1030 if (GETPOST("accountancy_code_buy") <= 0) {
1031 $_POST["accountancy_code_buy"] = ''; // If empty, we force to null
1032 }
1033 if ($id == DICT_TVA && GETPOSTISSET("code")) { // Spaces are not allowed into code for tax dictionary
1034 $_POST["code"] = preg_replace('/[^a-zA-Z0-9_\-\+]/', '', GETPOST("code"));
1035 }
1036
1037 $tablename = $tabname[$id];
1038 $tablename = preg_replace('/^'.preg_quote(MAIN_DB_PREFIX, '/').'/', '', $tablename);
1039
1040 // If check ok and action add, add the line
1041 if ($ok && GETPOST('actionadd')) {
1042 $newid = 0;
1043 if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldinsert)) {
1044 // Get free id for insert
1045 $sql = "SELECT MAX(".$tabrowid[$id].") as newid FROM ".MAIN_DB_PREFIX.$db->sanitize($tablename);
1046 $result = $db->query($sql);
1047 if ($result) {
1048 $obj = $db->fetch_object($result);
1049 $newid = ((int) $obj->newid) + 1;
1050 } else {
1051 dol_print_error($db);
1052 }
1053 }
1054
1055 // Add new entry
1056 $sql = "INSERT INTO ".MAIN_DB_PREFIX.$db->sanitize($tablename)." (";
1057 // List of fields
1058 if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldinsert)) {
1059 $sql .= $tabrowid[$id].",";
1060 }
1061 $sql .= $tabfieldinsert[$id];
1062 $sql .= ",active)";
1063 $sql .= " VALUES(";
1064
1065 // List of values
1066 if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldinsert)) {
1067 $sql .= ((int) $newid).",";
1068 }
1069 $i = 0;
1070 foreach ($listfieldinsert as $f => $value) {
1071 $keycode = (isset($listfieldvalue[$i]) ? $listfieldvalue[$i] : '');
1072 if (empty($keycode)) {
1073 $keycode = $value;
1074 }
1075
1076 if ($value == 'price' || preg_match('/^amount/i', $value)) {
1077 $_POST[$keycode] = price2num(GETPOST($keycode), 'MU');
1078 } elseif ($value == 'taux' || $value == 'localtax1') {
1079 $_POST[$keycode] = price2num(GETPOST($keycode), 8); // Note that localtax2 can be a list of rates separated by coma like X:Y:Z
1080 } elseif ($value == 'entity') {
1081 $_POST[$keycode] = (int) getEntity($tablename, 0);
1082 }
1083
1084 if ($i) {
1085 $sql .= ",";
1086 }
1087
1088 if ($keycode == 'sortorder') { // For column name 'sortorder', we use the field name 'position'
1089 $sql .= GETPOSTINT('position');
1090 } elseif (GETPOST($keycode) == '' && !($keycode == 'code' && $id == DICT_TVA)) {
1091 $sql .= "null"; // For vat, we want/accept code = ''
1092 } elseif ($keycode == 'content') {
1093 $sql .= "'".$db->escape(GETPOST($keycode, 'restricthtml'))."'";
1094 } elseif (in_array($keycode, array('joinfile', 'private', 'pos', 'position', 'scale', 'use_default'))) {
1095 $sql .= GETPOSTINT($keycode);
1096 } else {
1097 $sql .= "'".$db->escape(GETPOST($keycode, 'alphanohtml'))."'";
1098 }
1099
1100 $i++;
1101 }
1102 $sql .= ",1)";
1103
1104 dol_syslog("actionadd", LOG_DEBUG);
1105 $resql = $db->query($sql);
1106 if ($resql) { // Add is ok
1107 setEventMessages($langs->transnoentities("RecordCreatedSuccessfully"), null, 'mesgs');
1108
1109 // PostgreSQL: when we forced the rowid we must bump the matching <table>_<rowid_col>_seq
1110 // so the next auto-increment insert does not collide with our chosen value (#36510).
1111 if ($db->type == 'pgsql' && $tabrowid[$id] && !in_array($tabrowid[$id], $listfieldinsert)) {
1112 $db->query("SELECT setval(pg_get_serial_sequence('".$db->escape(MAIN_DB_PREFIX.$db->sanitize($tablename))."', '".$db->escape($tabrowid[$id])."'), GREATEST((SELECT MAX(".$db->sanitize($tabrowid[$id]).") FROM ".MAIN_DB_PREFIX.$db->sanitize($tablename)."), 1))");
1113 }
1114
1115 // Clean $_POST array, we keep only id of dictionary
1116 if ($id == DICT_TVA && GETPOSTINT('country') > 0) {
1117 $search_country_id = GETPOSTINT('country');
1118 }
1119 $_POST = array('id' => $id);
1120 } else {
1121 if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
1122 $langs->load('errors');
1123 setEventMessages($langs->transnoentities("ErrorRecordAlreadyExists"), null, 'errors');
1124 } else {
1125 dol_print_error($db);
1126 }
1127 }
1128 }
1129
1130 // If verif ok and action modify, modify the line
1131 if ($ok && GETPOST('actionmodify')) {
1132 if ($tabrowid[$id]) {
1133 $rowidcol = $tabrowid[$id];
1134 } else {
1135 $rowidcol = "rowid";
1136 }
1137
1138 // Modify entry
1139 $sql = "UPDATE ".MAIN_DB_PREFIX.$db->sanitize($tablename)." SET ";
1140 // Update fields value
1141 if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldmodify)) {
1142 $sql .= $tabrowid[$id]."=";
1143 $sql .= "'".$db->escape($rowid)."', ";
1144 }
1145 $i = 0;
1146 foreach ($listfieldmodify as $field) {
1147 $keycode = empty($listfieldvalue[$i]) ? '' : $listfieldvalue[$i];
1148 if (empty($keycode)) {
1149 $keycode = $field;
1150 }
1151
1152 if ($field == 'price' || preg_match('/^amount/i', $field)) {
1153 $_POST[$keycode] = price2num(GETPOST($keycode), 'MU');
1154 } elseif ($field == 'taux' || $field == 'localtax1') {
1155 $_POST[$keycode] = price2num(GETPOST($keycode), 8); // Note that localtax2 can be a list of rates separated by coma like X:Y:Z
1156 } elseif ($field == 'entity') {
1157 $_POST[$keycode] = (int) getEntity($tablename, 0);
1158 }
1159
1160 if ($i) {
1161 $sql .= ",";
1162 }
1163 $sql .= $field."=";
1164 if ($keycode == 'sortorder') { // For column name 'sortorder', we use the field name 'position'
1165 $sql .= GETPOSTINT('position');
1166 } elseif (GETPOST($keycode) == '' && !($keycode == 'code' && $id == DICT_TVA)) {
1167 $sql .= "null"; // For vat, we want/accept code = ''
1168 } elseif ($keycode == 'content') {
1169 $sql .= "'".$db->escape(GETPOST($keycode, 'restricthtml'))."'";
1170 } elseif (in_array($keycode, array('joinfile', 'private', 'pos', 'position', 'scale', 'use_default'))) {
1171 $sql .= GETPOSTINT($keycode);
1172 } else {
1173 $sql .= "'".$db->escape(GETPOST($keycode, 'alphanohtml'))."'";
1174 }
1175
1176 $i++;
1177 }
1178 if (in_array($rowidcol, array('code', 'code_iso'))) {
1179 $sql .= " WHERE ".$db->sanitize($rowidcol)." = '".$db->escape($rowid)."'";
1180 } else {
1181 $sql .= " WHERE ".$db->sanitize($rowidcol)." = ".((int) $rowid);
1182 }
1183 if (in_array('entity', $listfieldmodify)) {
1184 $sql .= " AND entity = ".((int) getEntity($tablename, 0));
1185 }
1186
1187 dol_syslog("actionmodify", LOG_DEBUG);
1188 //print $sql;
1189 $resql = $db->query($sql);
1190 if (!$resql) {
1191 setEventMessages($db->error(), null, 'errors');
1192 }
1193 }
1194
1195 if (!$ok && GETPOST('actionadd')) {
1196 $action = 'create';
1197 }
1198 if (!$ok && GETPOST('actionmodify')) {
1199 $action = 'edit';
1200 }
1201 }
1202
1203 if ($action == 'confirm_delete' && $confirm == 'yes') { // delete
1204 if ($tabrowid[$id]) {
1205 $rowidcol = $tabrowid[$id];
1206 } else {
1207 $rowidcol = "rowid";
1208 }
1209
1210 $tablename = $tabname[$id];
1211 $tablename = preg_replace('/^'.preg_quote(MAIN_DB_PREFIX, '/').'/', '', $tablename);
1212
1213 $sql = "DELETE FROM ".MAIN_DB_PREFIX.$db->sanitize($tablename)." WHERE ".$db->sanitize($rowidcol)." = '".$db->escape($rowid)."'".($entity != '' ? " AND entity = ".(int) $entity : '');
1214
1215 dol_syslog("delete", LOG_DEBUG);
1216 $result = $db->query($sql);
1217 if (!$result) {
1218 if ($db->errno() == 'DB_ERROR_CHILD_EXISTS') {
1219 setEventMessages($langs->transnoentities("ErrorRecordIsUsedByChild"), null, 'errors');
1220 } else {
1221 dol_print_error($db);
1222 }
1223 }
1224 }
1225
1226 // activate
1227 if ($action == $acts[0]) {
1228 if ($tabrowid[$id]) {
1229 $rowidcol = $tabrowid[$id];
1230 } else {
1231 $rowidcol = "rowid";
1232 }
1233
1234 $tablename = $tabname[$id];
1235 $tablename = preg_replace('/^'.preg_quote(MAIN_DB_PREFIX, '/').'/', '', $tablename);
1236
1237 if ($rowid) {
1238 $sql = "UPDATE ".MAIN_DB_PREFIX.$db->sanitize($tablename)." SET active = 1 WHERE ".$db->sanitize($rowidcol)." = ".((int) $rowid).($entity != '' ? " AND entity = ".(int) $entity : '');
1239 } elseif ($code) {
1240 $sql = "UPDATE ".MAIN_DB_PREFIX.$db->sanitize($tablename)." SET active = 1 WHERE code = '".$db->escape(dol_escape_htmltag($code))."'".($entity != '' ? " AND entity = ".(int) $entity : '');
1241 } else {
1242 $sql = null;
1243 }
1244
1245 if ($sql !== null) {
1246 $result = $db->query($sql);
1247 if (!$result) {
1248 dol_print_error($db);
1249 }
1250 } else {
1251 dol_print_error(null, "No DB entry or no code");
1252 }
1253 }
1254
1255 // disable
1256 if ($action == $acts[1]) {
1257 if ($tabrowid[$id]) {
1258 $rowidcol = $tabrowid[$id];
1259 } else {
1260 $rowidcol = "rowid";
1261 }
1262
1263 $tablename = $tabname[$id];
1264 $tablename = preg_replace('/^'.preg_quote(MAIN_DB_PREFIX, '/').'/', '', $tablename);
1265
1266 if ($rowid) {
1267 $sql = "UPDATE ".MAIN_DB_PREFIX.$db->sanitize($tablename)." SET active = 0 WHERE ".$db->sanitize($rowidcol)." = '".$db->escape($rowid)."'".($entity != '' ? " AND entity = ".(int) $entity : '');
1268 } elseif ($code) {
1269 $sql = "UPDATE ".MAIN_DB_PREFIX.$db->sanitize($tablename)." SET active = 0 WHERE code = '".$db->escape(dol_escape_htmltag($code))."'".($entity != '' ? " AND entity = ".(int) $entity : '');
1270 } else {
1271 $sql = null;
1272 }
1273
1274 if ($sql !== null) {
1275 $result = $db->query($sql);
1276 if (!$result) {
1277 dol_print_error($db);
1278 }
1279 } else {
1280 dol_print_error(null, "No DB entry or no code");
1281 }
1282 }
1283
1284 // favorite
1285 if ($action == 'activate_favorite') {
1286 if ($tabrowid[$id]) {
1287 $rowidcol = $tabrowid[$id];
1288 } else {
1289 $rowidcol = "rowid";
1290 }
1291
1292 $tablename = $tabname[$id];
1293 $tablename = preg_replace('/^'.preg_quote(MAIN_DB_PREFIX, '/').'/', '', $tablename);
1294
1295 if ($rowid) {
1296 $sql = "UPDATE ".MAIN_DB_PREFIX.$db->sanitize($tablename)." SET favorite = 1 WHERE ".$db->sanitize($rowidcol)." = '".$db->escape($rowid)."'".($entity != '' ? " AND entity = ".(int) $entity : '');
1297 } elseif ($code) {
1298 $sql = "UPDATE ".MAIN_DB_PREFIX.$db->sanitize($tablename)." SET favorite = 1 WHERE code = '".$db->escape(dol_escape_htmltag($code))."'".($entity != '' ? " AND entity = ".(int) $entity : '');
1299 } else {
1300 $sql = null;
1301 }
1302
1303 if ($sql !== null) {
1304 $result = $db->query($sql);
1305 if (!$result) {
1306 dol_print_error($db);
1307 }
1308 } else {
1309 dol_print_error(null, "No DB entry or no code");
1310 }
1311 }
1312
1313 // disable favorite
1314 if ($action == 'disable_favorite') {
1315 if ($tabrowid[$id]) {
1316 $rowidcol = $tabrowid[$id];
1317 } else {
1318 $rowidcol = "rowid";
1319 }
1320
1321 $tablename = $tabname[$id];
1322 $tablename = preg_replace('/^'.preg_quote(MAIN_DB_PREFIX, '/').'/', '', $tablename);
1323
1324 if ($rowid) {
1325 $sql = "UPDATE ".MAIN_DB_PREFIX.$db->sanitize($tablename)." SET favorite = 0 WHERE ".$db->sanitize($rowidcol)." = '".$db->escape($rowid)."'".($entity != '' ? " AND entity = ".(int) $entity : '');
1326 } elseif ($code) {
1327 $sql = "UPDATE ".MAIN_DB_PREFIX.$db->sanitize($tablename)." SET favorite = 0 WHERE code = '".$db->escape(dol_escape_htmltag($code))."'".($entity != '' ? " AND entity = ".(int) $entity : '');
1328 } else {
1329 $sql = null;
1330 }
1331
1332 if ($sql !== null) {
1333 $result = $db->query($sql);
1334 if (!$result) {
1335 dol_print_error($db);
1336 }
1337 } else {
1338 dol_print_error(null, "No DB entry or no code");
1339 }
1340 }
1341
1342 // Is in EEC - Activate
1343 if ($action == 'activate_eec') {
1344 if ($tabrowid[$id]) {
1345 $rowidcol = $tabrowid[$id];
1346 } else {
1347 $rowidcol = "rowid";
1348 }
1349
1350 $tablename = $tabname[$id];
1351 $tablename = preg_replace('/^'.preg_quote(MAIN_DB_PREFIX, '/').'/', '', $tablename);
1352
1353 if ($rowid) {
1354 $sql = "UPDATE ".MAIN_DB_PREFIX.$db->sanitize($tablename)." SET eec = 1 WHERE ".$db->sanitize($rowidcol)." = '".$db->escape($rowid)."'".($entity != '' ? " AND entity = ".(int) $entity : '');
1355 } elseif ($code) {
1356 $sql = "UPDATE ".MAIN_DB_PREFIX.$db->sanitize($tablename)." SET eec = 1 WHERE code = '".$db->escape(dol_escape_htmltag($code))."'".($entity != '' ? " AND entity = ".(int) $entity : '');
1357 } else {
1358 $sql = null;
1359 }
1360
1361 if ($sql !== null) {
1362 $result = $db->query($sql);
1363 if (!$result) {
1364 dol_print_error($db);
1365 }
1366 } else {
1367 dol_print_error(null, "No DB entry or no code");
1368 }
1369 }
1370
1371 // Is in EEC - Disable
1372 if ($action == 'disable_eec') {
1373 if ($tabrowid[$id]) {
1374 $rowidcol = $tabrowid[$id];
1375 } else {
1376 $rowidcol = "rowid";
1377 }
1378
1379 $tablename = $tabname[$id];
1380 $tablename = preg_replace('/^'.preg_quote(MAIN_DB_PREFIX, '/').'/', '', $tablename);
1381
1382 if ($rowid) {
1383 $sql = "UPDATE ".MAIN_DB_PREFIX.$db->sanitize($tablename)." SET eec = 0 WHERE ".$db->sanitize($rowidcol)." = '".$db->escape($rowid)."'".($entity != '' ? " AND entity = ".(int) $entity : '');
1384 } elseif ($code) {
1385 $sql = "UPDATE ".MAIN_DB_PREFIX.$db->sanitize($tablename)." SET eec = 0 WHERE code = '".$db->escape(dol_escape_htmltag($code))."'".($entity != '' ? " AND entity = ".(int) $entity : '');
1386 } else {
1387 $sql = null;
1388 }
1389
1390 if ($sql !== null) {
1391 $result = $db->query($sql);
1392 if (!$result) {
1393 dol_print_error($db);
1394 }
1395 } else {
1396 dol_print_error(null, "No DB entry or no code");
1397 }
1398 }
1399
1400 // Is in Sepa - Activate
1401 if ($action == 'activate_sepa') {
1402 if ($tabrowid[$id]) {
1403 $rowidcol = $tabrowid[$id];
1404 } else {
1405 $rowidcol = "rowid";
1406 }
1407
1408 $tablename = $tabname[$id];
1409 $tablename = preg_replace('/^'.preg_quote(MAIN_DB_PREFIX, '/').'/', '', $tablename);
1410
1411 if ($rowid) {
1412 $sql = "UPDATE ".MAIN_DB_PREFIX.$db->sanitize($tablename)." SET sepa = 1 WHERE ".$db->sanitize($rowidcol)." = '".$db->escape($rowid)."'".($entity != '' ? " AND entity = ".(int) $entity : '');
1413 } elseif ($code) {
1414 $sql = "UPDATE ".MAIN_DB_PREFIX.$db->sanitize($tablename)." SET sepa = 1 WHERE code = '".$db->escape(dol_escape_htmltag($code))."'".($entity != '' ? " AND entity = ".(int) $entity : '');
1415 } else {
1416 $sql = null;
1417 }
1418
1419 if ($sql !== null) {
1420 $result = $db->query($sql);
1421 if (!$result) {
1422 dol_print_error($db);
1423 }
1424 } else {
1425 dol_print_error(null, "No DB entry or no code");
1426 }
1427 }
1428
1429 // Is in Sepa - Disable
1430 if ($action == 'disable_sepa') {
1431 if ($tabrowid[$id]) {
1432 $rowidcol = $tabrowid[$id];
1433 } else {
1434 $rowidcol = "rowid";
1435 }
1436
1437 $tablename = $tabname[$id];
1438 $tablename = preg_replace('/^'.preg_quote(MAIN_DB_PREFIX, '/').'/', '', $tablename);
1439
1440 if ($rowid) {
1441 $sql = "UPDATE ".MAIN_DB_PREFIX.$db->sanitize($tablename)." SET sepa = 0 WHERE ".$db->sanitize($rowidcol)." = '".$db->escape($rowid)."'".($entity != '' ? " AND entity = ".(int) $entity : '');
1442 } elseif ($code) {
1443 $sql = "UPDATE ".MAIN_DB_PREFIX.$db->sanitize($tablename)." SET sepa = 0 WHERE code = '".$db->escape(dol_escape_htmltag($code))."'".($entity != '' ? " AND entity = ".(int) $entity : '');
1444 } else {
1445 $sql = null;
1446 }
1447
1448 if ($sql !== null) {
1449 $result = $db->query($sql);
1450 if (!$result) {
1451 dol_print_error($db);
1452 }
1453 } else {
1454 dol_print_error(null, "No DB entry or no code");
1455 }
1456 }
1457}
1458
1459
1460/*
1461 * View
1462 */
1463global $form, $formother; // Used in dictFieldList() below
1464
1465$form = new Form($db);
1466$formother = new FormOther($db);
1467
1468$title = $langs->trans("DictionarySetup");
1469
1470llxHeader('', $title, '', '', 0, 0, '', '', '', 'mod-admin page-dict');
1471
1472if (GETPOSTINT('id') == DICT_SOCIALNETWORKS && $from == 'socialnetworksetup') {
1473 $head = socialnetwork_prepare_head();
1474 print dol_get_fiche_head($head, 'dict', $langs->trans('MenuDict'), -1, 'user');
1475}
1476
1477
1478$linkback = '';
1479if ($id && empty($from)) {
1480 $title .= ' - '.$langs->trans($tablib[$id]);
1481 $linkback = '<a href="'.$_SERVER['PHP_SELF'].'">'.img_picto($langs->trans("BackToDictionaryList"), 'back', 'class="pictofixedwidth"').'<span class="hideonsmartphone">'.$langs->trans("BackToDictionaryList").'</span></a>';
1482}
1483$titlepicto = 'title_setup';
1484if ($id == DICT_TVA && GETPOST('from') == 'accountancy') {
1485 $title = $langs->trans("MenuVatAccounts");
1486 $titlepicto = 'accountancy';
1487}
1488if ($id == DICT_CHARGESOCIALES && GETPOST('from') == 'accountancy') {
1489 $title = $langs->trans("MenuTaxAccounts");
1490 $titlepicto = 'accountancy';
1491}
1492
1493$param = '&id='.urlencode((string) ($id));
1494if ($search_country_id || GETPOSTISSET('page') || GETPOST('button_removefilter', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter_x', 'alpha')) {
1495 $param .= '&search_country_id='.urlencode((string) ($search_country_id ? $search_country_id : -1));
1496}
1497if ($search_code != '') {
1498 $param .= '&search_code='.urlencode($search_code);
1499}
1500if ($search_active != '') {
1501 $param .= '&search_active='.urlencode($search_active);
1502}
1503if ($entity != '') {
1504 $param .= '&entity='.(int) $entity;
1505}
1506if ($from) {
1507 $param .= '&from='.urlencode($from);
1508}
1509$paramwithsearch = $param;
1510if ($sortorder) {
1511 $paramwithsearch .= '&sortorder='.urlencode($sortorder);
1512}
1513if ($sortfield) {
1514 $paramwithsearch .= '&sortfield='.urlencode($sortfield);
1515}
1516if ($from) {
1517 $paramwithsearch .= '&from='.urlencode($from);
1518}
1519
1520
1521// Confirmation of the deletion of the line
1522if ($action == 'delete') {
1523 print $form->formconfirm($_SERVER["PHP_SELF"].'?'.($page ? 'page='.$page.'&' : '').'rowid='.urlencode($rowid).'&code='.urlencode($code).$paramwithsearch, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_delete', '', 0, 1);
1524}
1525
1526// Show a dictionary
1527if ($id > 0) {
1528 // Complete search values request with sort criteria
1529 $sqlfields = $tabsql[$id];
1530
1531 $tablecode = 't.code';
1532 $tableprefix = '';
1533 $tableprefixarray = array(
1534 DICT_FORME_JURIDIQUE => 'f.code',
1535 DICT_DEPARTEMENTS => 'd.code_departement',
1536 DICT_REGIONS => 'r.code_region',
1537 DICT_COUNTRY => 'c.code',
1538 DICT_CIVILITY => 'c.code',
1539 DICT_ACTIONCOMM => 'a.code',
1540 DICT_CHARGESOCIALES => 'a.code',
1541 DICT_TYPENT => 't.code',
1542 DICT_CURRENCIES => 'c.code_iso',
1543 DICT_ECOTAXE => 'e.code',
1544 DICT_HOLIDAY_TYPES => 'h.code',
1545 DICT_HRM_PUBLIC_HOLIDAY => 'a.code',
1546 DICT_UNITS => 'r.code',
1547 DICT_SOCIALNETWORKS => 's.code',
1548 45 => 'f.code',
1549 46 => 'f.code',
1550 47 => 'f.code',
1551 48 => 'f.code',
1552 );
1553 if (!empty($tableprefixarray[$id])) {
1554 $tablecode = $tableprefixarray[$id];
1555 $tableprefix = preg_replace('/\..*$/', '.', $tablecode);
1556 }
1557 $reg = array();
1558 if (empty($tableprefix) && preg_match('/SELECT ([a-z]\.)rowid/i', $sqlfields, $reg)) {
1559 $tableprefix = $reg[1];
1560 }
1561
1562 $sql = $sqlfields;
1563 if (!preg_match('/ WHERE /', $sql)) {
1564 $sql .= " WHERE 1 = 1";
1565 }
1566 if ($search_country_id > 0) {
1567 if ($id == DICT_HRM_PUBLIC_HOLIDAY || $id == DICT_HOLIDAY_TYPES) {
1568 $sql .= " AND (c.rowid IS NULL OR c.rowid = 0 OR c.rowid = ".((int) $search_country_id).")";
1569 } else {
1570 $sql .= " AND c.rowid = ".((int) $search_country_id);
1571 }
1572 }
1573 if ($search_code != '') {
1574 $sql .= natural_search($tablecode, $search_code);
1575 }
1576 if ($search_active == 'yes') {
1577 $sql .= " AND ".$db->sanitize($tableprefix)."active = 1";
1578 } elseif ($search_active == 'no') {
1579 $sql .= " AND ".$db->sanitize($tableprefix)."active = 0";
1580 }
1581
1582 // Count total nb of records
1583 $nbtotalofrecords = '';
1584 if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
1585 /* The fast and low memory method to get and count full list converts the sql into a sql count */
1586 $sqlforcount = preg_replace('/^.*\sFROM\s/', 'SELECT COUNT(*) as nbtotalofrecords FROM ', $sql);
1587 $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount);
1588 $resql = $db->query($sqlforcount);
1589 if ($resql) {
1590 $objforcount = $db->fetch_object($resql);
1591 $nbtotalofrecords = $objforcount->nbtotalofrecords;
1592 } else {
1593 dol_print_error($db);
1594 }
1595
1596 if (($page * $listlimit) > $nbtotalofrecords) { // if total resultset is smaller than the paging size (filtering), goto and load page 0
1597 $page = 0;
1598 $offset = 0;
1599 }
1600 $db->free($resql);
1601 }
1602
1603 if ($sortfield) {
1604 // If sort order is "country", we use country_code instead
1605 if ($sortfield == 'country') {
1606 $sortfield = 'country_code';
1607 }
1608 $sql .= $db->order($sortfield, $sortorder);
1609 $sql .= ", ";
1610 // Clear the required sort criteria for the tabsqlsort to be able to force it with selected value
1611 $tabsqlsort[$id] = preg_replace('/([a-z]+\.)?'.$sortfield.' '.$sortorder.',/i', '', $tabsqlsort[$id]);
1612 $tabsqlsort[$id] = preg_replace('/([a-z]+\.)?'.$sortfield.',/i', '', $tabsqlsort[$id]);
1613 } else {
1614 $sql .= " ORDER BY ";
1615 }
1616 $sql .= $tabsqlsort[$id];
1617
1618 $sql .= $db->plimit($listlimit + 1, $offset);
1619
1620 //print $sql;
1621
1622 if (empty($tabfield[$id])) {
1623 dol_print_error($db, 'The table with id '.$id.' has no array tabfield defined');
1624 exit;
1625 }
1626 $fieldlist = explode(',', $tabfield[$id]);
1627
1628 // Definition of array of fields for columns.
1629 // $val['label'] is the label of column shown into the selector of columns, $val['checked'] is 1 when
1630 // the column is shown (main fields are shown by default, other ones only when selected by user).
1631 $arrayfields = array();
1632 $mainfieldlist = explode(',', str_replace(' ', '', empty($tabfieldmain[$id]) ? $tabfield[$id] : $tabfieldmain[$id])); // Fields shown by default
1633 foreach ($fieldlist as $key => $value) {
1634 if (empty($value) || in_array($value, array('entity', 'region_id', 'country_id', 'department_buyer_id'))) {
1635 continue; // Technical fields are never displayed and not selectable
1636 }
1637 $arrayfields[$value] = array(
1638 'label' => dictFieldLabel($value, $tabname[$id], $tablib[$id]),
1639 'checked' => (in_array($value, $mainfieldlist) ? 1 : 0),
1640 'position' => (int) $key
1641 );
1642 }
1643
1644 print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$id.'" method="POST" spellcheck="false">';
1645 print '<input type="hidden" name="token" value="'.newToken().'">';
1646 print '<input type="hidden" name="from" value="'.dol_escape_htmltag($from).'">';
1647 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
1648
1649 // Special warning for VAT dictionary
1650 if ($id == DICT_TVA && !getDolGlobalString('FACTURE_TVAOPTION')) {
1651 print info_admin($langs->trans("VATIsUsedIsOff", $langs->transnoentities("Setup"), $langs->transnoentities("CompanyFoundation")));
1652 print "<br>\n";
1653 }
1654
1655 // List of available record in database
1656 dol_syslog("htdocs/admin/dict", LOG_DEBUG);
1657
1658 $resql = $db->query($sql);
1659 if ($resql) {
1660 $num = $db->num_rows($resql);
1661 $i = 0;
1662
1663 $massactionbutton = $linkback;
1664
1665 $newcardbutton = '';
1666 /*$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'));
1667 $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'));
1668 $newcardbutton .= dolGetButtonTitleSeparator();
1669 */
1670 $newcardbutton .= dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/admin/dict.php?action=create'.$param.'&backtopage='.urlencode($_SERVER['PHP_SELF']), '', $permissiontoadd);
1671
1672 print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'tools', 0, $newcardbutton, '', $listlimit, 'listlimit', 0, 1);
1673
1674
1675 if ($action == 'create') {
1676 // Form to add a new line
1677 if ($tabname[$id]) {
1678 $withentity = null;
1679
1680 $fieldlist = explode(',', $tabfield[$id]);
1681
1682 print '<div class="div-table-responsive-no-min">';
1683 print '<table class="noborder centpercent">';
1684
1685 // Line for title
1686 print '<!-- line title to add new entry -->';
1687 $tdsoffields = '<tr class="liste_titre">';
1688 foreach ($fieldlist as $field => $value) {
1689 if ($value == 'entity') {
1690 $withentity = (int) getEntity($tabname[$id], 0);
1691 continue;
1692 }
1693
1694 // Define field friendly name from its technical name
1695 $valuetoshow = ucfirst($value); // Par default
1696 $valuetoshow = $langs->trans($valuetoshow); // try to translate
1697 $class = '';
1698
1699 if ($value == 'pos') {
1700 $valuetoshow = $langs->trans("Position");
1701 $class = 'right';
1702 }
1703 if ($value == 'source') {
1704 $valuetoshow = $langs->trans("Contact");
1705 }
1706 if ($value == 'price') {
1707 $valuetoshow = $langs->trans("PriceUHT");
1708 }
1709 if ($value == 'taux') {
1710 if ($tabname[$id] != "c_revenuestamp") {
1711 $valuetoshow = $langs->trans("Rate");
1712 } else {
1713 $valuetoshow = $langs->trans("Amount");
1714 }
1715 $class = 'center';
1716 }
1717 if ($value == 'localtax1_type') {
1718 $valuetoshow = $langs->trans("UseLocalTax")." 2";
1719 $class = "center";
1720 $sortable = 0;
1721 }
1722 if ($value == 'localtax1') {
1723 $valuetoshow = $langs->trans("RateOfTaxN", '2');
1724 $class = "center minwidth75";
1725 }
1726 if ($value == 'localtax2_type') {
1727 $valuetoshow = $langs->trans("UseLocalTax")." 3";
1728 $class = "center";
1729 $sortable = 0;
1730 }
1731 if ($value == 'localtax2') {
1732 $valuetoshow = $langs->trans("RateOfTaxN", '3');
1733 $class = "center minwidth75";
1734 }
1735 if ($value == 'type_vat') {
1736 $valuetoshow = $langs->trans("VATType");
1737 }
1738 if ($value == 'organization') {
1739 $valuetoshow = $langs->trans("Organization");
1740 }
1741 if ($value == 'lang') {
1742 $valuetoshow = $langs->trans("Language");
1743 }
1744 if ($value == 'type') {
1745 if ($tabname[$id] == "c_paiement") {
1746 $valuetoshow = $form->textwithtooltip($langs->trans("Type"), $langs->trans("TypePaymentDesc"), 2, 1, img_help(1, ''));
1747 } else {
1748 $valuetoshow = $langs->trans("Type");
1749 }
1750 }
1751 if ($value == 'code') {
1752 $valuetoshow = $langs->trans("Code");
1753 $class = 'maxwidth100';
1754 }
1755 if ($value == 'libelle' || $value == 'label') {
1756 $valuetoshow = $form->textwithtooltip($langs->trans("Label"), $langs->trans("LabelUsedByDefault"), 2, 1, img_help(1, ''));
1757 }
1758 if ($value == 'libelle_facture') {
1759 $valuetoshow = $form->textwithtooltip($langs->trans("LabelOnDocuments"), $langs->trans("LabelUsedByDefault"), 2, 1, img_help(1, ''));
1760 }
1761 if ($value == 'deposit_percent') {
1762 $valuetoshow = $langs->trans('DepositPercent');
1763 $class = 'right';
1764 }
1765 if ($value == 'country') {
1766 if (in_array('region_id', $fieldlist)) {
1767 //print '<td>&nbsp;</td>';
1768 continue;
1769 } // For region page, we do not show the country input
1770 $valuetoshow = $langs->trans("Country");
1771 }
1772 if ($value == 'department_buyer') {
1773 $valuetoshow = '';
1774 }
1775 if ($value == 'recuperableonly') {
1776 $valuetoshow = $langs->trans("NPR");
1777 $class = "center";
1778 }
1779 if ($value == 'einvoice_vatex') {
1780 $valuetoshow = $langs->trans("VATExemptionCode");
1781 $class = "center";
1782 }
1783 if ($value == 'nbjour') {
1784 $valuetoshow = $langs->trans("NbOfDays");
1785 $class = 'right';
1786 }
1787 if ($value == 'type_cdr') {
1788 $valuetoshow = $langs->trans("AtEndOfMonth");
1789 $class = "center";
1790 }
1791 if ($value == 'decalage') {
1792 $valuetoshow = $langs->trans("Offset");
1793 $class = 'right';
1794 }
1795 if ($value == 'width' || $value == 'nx') {
1796 $valuetoshow = $langs->trans("Width");
1797 }
1798 if ($value == 'height' || $value == 'ny') {
1799 $valuetoshow = $langs->trans("Height");
1800 }
1801 if ($value == 'unit' || $value == 'metric') {
1802 $valuetoshow = $langs->trans("MeasuringUnit");
1803 }
1804 if ($value == 'region_id' || $value == 'country_id' || $value == 'department_buyer_id') {
1805 $valuetoshow = '';
1806 }
1807 if ($value == 'accountancy_code') {
1808 $valuetoshow = $langs->trans("AccountancyCode");
1809 }
1810 if ($value == 'accountancy_code_sell') {
1811 $valuetoshow = $langs->trans("AccountancyCodeSell");
1812 }
1813 if ($value == 'accountancy_code_buy') {
1814 $valuetoshow = $langs->trans("AccountancyCodeBuy");
1815 }
1816 if ($value == 'pcg_version' || $value == 'fk_pcg_version') {
1817 $valuetoshow = $langs->trans("Pcg_version");
1818 }
1819 if ($value == 'account_parent') {
1820 $valuetoshow = $langs->trans("Accountparent");
1821 }
1822 if ($value == 'pcg_type') {
1823 $valuetoshow = $langs->trans("Pcg_type");
1824 }
1825 if ($value == 'pcg_subtype') {
1826 $valuetoshow = $langs->trans("Pcg_subtype");
1827 }
1828 if ($value == 'sortorder') {
1829 $valuetoshow = $langs->trans("SortOrder");
1830 $class = 'center';
1831 }
1832 if ($value == 'short_label') {
1833 $valuetoshow = $langs->trans("ShortLabel");
1834 }
1835 if ($value == 'fk_parent') {
1836 $valuetoshow = $langs->trans("ParentID");
1837 $class = 'center';
1838 }
1839 if ($value == 'range_account') {
1840 $valuetoshow = $langs->trans("Range");
1841 }
1842 if ($value == 'sens') {
1843 $valuetoshow = $langs->trans("Sens");
1844 }
1845 if ($value == 'category_type') {
1846 $valuetoshow = $langs->trans("Calculated");
1847 }
1848 if ($value == 'formula') {
1849 $valuetoshow = $langs->trans("Formula");
1850 }
1851 if ($value == 'paper_size') {
1852 $valuetoshow = $langs->trans("PaperSize");
1853 }
1854 if ($value == 'orientation') {
1855 $valuetoshow = $langs->trans("Orientation");
1856 }
1857 if ($value == 'leftmargin') {
1858 $valuetoshow = $langs->trans("LeftMargin");
1859 }
1860 if ($value == 'topmargin') {
1861 $valuetoshow = $langs->trans("TopMargin");
1862 }
1863 if ($value == 'spacex') {
1864 $valuetoshow = $langs->trans("SpaceX");
1865 }
1866 if ($value == 'spacey') {
1867 $valuetoshow = $langs->trans("SpaceY");
1868 }
1869 if ($value == 'font_size') {
1870 $valuetoshow = $langs->trans("FontSize");
1871 }
1872 if ($value == 'custom_x') {
1873 $valuetoshow = $langs->trans("CustomX");
1874 }
1875 if ($value == 'custom_y') {
1876 $valuetoshow = $langs->trans("CustomY");
1877 }
1878 if ($value == 'percent') {
1879 $valuetoshow = $langs->trans("Percentage");
1880 }
1881 if ($value == 'affect') {
1882 $valuetoshow = $langs->trans("WithCounter");
1883 }
1884 if ($value == 'delay') {
1885 $valuetoshow = $langs->trans("NoticePeriod");
1886 }
1887 if ($value == 'newbymonth') {
1888 $valuetoshow = $langs->trans("NewByMonth");
1889 }
1890 if ($value == 'fk_tva') {
1891 $valuetoshow = $langs->trans("VAT");
1892 }
1893 if ($value == 'range_ik') {
1894 $valuetoshow = $langs->trans("RangeIk");
1895 }
1896 if ($value == 'fk_c_exp_tax_cat') {
1897 $valuetoshow = $langs->trans("CarCategory");
1898 }
1899 if ($value == 'revenuestamp_type') {
1900 $valuetoshow = $langs->trans('TypeOfRevenueStamp');
1901 }
1902 if ($value == 'use_default') {
1903 $valuetoshow = $langs->trans('Default');
1904 $class = 'center';
1905 }
1906 if ($value == 'unit_type') {
1907 $valuetoshow = $langs->trans('TypeOfUnit');
1908 }
1909 if ($value == 'public' && $tablib[$id] == 'TicketDictCategory') {
1910 $valuetoshow = $langs->trans('TicketGroupIsPublic');
1911 $class = 'center';
1912 }
1913 if ($value == 'block_if_negative') {
1914 $valuetoshow = $langs->trans('BlockHolidayIfNegative');
1915 }
1916 if ($value == 'type_duration') {
1917 $valuetoshow = $langs->trans('Unit');
1918 }
1919
1920 if ($id == DICT_DEPARTEMENTS) { // Special case for state page
1921 if ($value == 'region_id') {
1922 $valuetoshow = '&nbsp;';
1923 $showfield = 1;
1924 }
1925 if ($value == 'region') {
1926 $valuetoshow = $langs->trans("Country").'/'.$langs->trans("Region");
1927 $showfield = 1;
1928 }
1929 }
1930
1931 if ($valuetoshow != '') {
1932 $tooltiphelp = (isset($tabcomplete[$tabname[$id]]['help'][$value]) ? $tabcomplete[$tabname[$id]]['help'][$value] : '');
1933
1934 $tdsoffields .= '<th'.($class ? ' class="'.$class.'"' : '').'>';
1935 if ($tooltiphelp && preg_match('/^http(s*):/i', $tooltiphelp)) {
1936 $tdsoffields .= '<a href="'.$tooltiphelp.'" target="_blank">'.$valuetoshow.' '.img_help(1, $valuetoshow).'</a>';
1937 } elseif ($tooltiphelp) {
1938 $tdsoffields .= $form->textwithpicto($valuetoshow, $tooltiphelp);
1939 } else {
1940 $tdsoffields .= $valuetoshow;
1941 }
1942 $tdsoffields .= '</th>';
1943 }
1944 }
1945
1946 if ($id == DICT_COUNTRY) {
1947 $tdsoffields .= '<th></th>';
1948 $tdsoffields .= '<th></th>';
1949 }
1950 $tdsoffields .= '<th>';
1951 $tdsoffields .= '<input type="hidden" name="id" value="'.$id.'">';
1952 if (!is_null($withentity)) {
1953 $tdsoffields .= '<input type="hidden" name="entity" value="'.$withentity.'">';
1954 }
1955 $tdsoffields .= '</th>';
1956 $tdsoffields .= '<th style="min-width: 26px;"></th>';
1957 $tdsoffields .= '<th style="min-width: 26px;"></th>';
1958 $tdsoffields .= '</tr>';
1959
1960 print $tdsoffields;
1961
1962
1963 // Line to enter new values
1964 print '<!-- line input to add new entry -->';
1965 print '<tr class="oddeven nodrag nodrop nohover">';
1966
1967 $obj = new stdClass();
1968 // If data was already input, we define them in obj to populate input fields.
1969 if (GETPOST('actionadd')) {
1970 foreach ($fieldlist as $key => $val) {
1971 if (GETPOST($val) != '') {
1972 $obj->$val = GETPOST($val);
1973 }
1974 }
1975 }
1976
1977 $tmpaction = 'create';
1978 $parameters = array('fieldlist' => $fieldlist, 'tabname' => $tabname[$id]);
1979 $reshook = $hookmanager->executeHooks('createDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
1980 $error = $hookmanager->error;
1981 $errors = $hookmanager->errors;
1982
1983 if ($id == DICT_REGIONS) {
1984 unset($fieldlist[2]); // Remove field ??? if dictionary Regions
1985 }
1986
1987 if (empty($reshook)) {
1988 dictFieldList($fieldlist, $obj, $tabname[$id], 'add');
1989 }
1990
1991 if ($id == DICT_COUNTRY) {
1992 print '<td></td>';
1993 print '<td></td>';
1994 print '<td></td>';
1995 }
1996 print '<td colspan="3" class="center">';
1997 if ($action != 'edit') {
1998 print '<input type="submit" class="button button-add small" name="actionadd" value="'.$langs->trans("Add").'">';
1999 } else {
2000 print '<input type="submit" class="button button-add small disabled" name="actionadd" value="'.$langs->trans("Add").'">';
2001 }
2002 print '</td>';
2003
2004 print "</tr>";
2005
2006 print '</table>';
2007 print '</div>';
2008 }
2009
2010 print '</form>';
2011
2012 print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$id.'" method="POST" spellcheck="false">';
2013 print '<input type="hidden" name="token" value="'.newToken().'">';
2014 print '<input type="hidden" name="from" value="'.dol_escape_htmltag(GETPOST('from', 'alpha')).'">';
2015 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
2016 }
2017
2018
2019 // Selection of columns to show (this also update the array $arrayfields with the setup of user)
2020 $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $contextpage, $conf->main_checkbox_left_column, 0);
2021
2022 $filterfound = 0;
2023 foreach ($fieldlist as $field => $value) {
2024 if ($value == 'entity') {
2025 continue;
2026 }
2027
2028 $showfield = 1; // By default
2029 if ($value == 'region_id' || $value == 'country_id' || $value == 'department_buyer_id') {
2030 $showfield = 0;
2031 }
2032 if (empty($arrayfields[$value]['checked'])) {
2033 $showfield = 0; // Column was not selected to be displayed
2034 }
2035
2036 if ($showfield) {
2037 if ($value == 'country') {
2038 $filterfound++;
2039 } elseif ($value == 'code') {
2040 $filterfound++;
2041 }
2042 }
2043 }
2044
2045 print '<div class="div-table-responsive">';
2046 print '<table class="noborder centpercent noborder">';
2047
2048 $colspan = 0;
2049
2050 // Title line with search input fields
2051 print '<!-- line title to search record -->'."\n";
2052 print '<tr class="liste_titre_filter">';
2053
2054 // Action button
2055 if ($conf->main_checkbox_left_column) {
2056 print '<td class="liste_titre center maxwidthsearch">';
2057 if ($filterfound) {
2058 $searchpicto = $form->showFilterAndCheckAddButtons(0);
2059 print $searchpicto;
2060 }
2061 print '</td>';
2062 $colspan++;
2063 }
2064
2065 foreach ($fieldlist as $field => $value) {
2066 if ($value == 'entity') {
2067 continue;
2068 }
2069
2070 $showfield = 1; // By default
2071 if ($value == 'region_id' || $value == 'country_id' || $value == 'department_buyer_id') {
2072 $showfield = 0;
2073 }
2074 if (empty($arrayfields[$value]['checked'])) {
2075 $showfield = 0; // Column was not selected to be displayed
2076 }
2077
2078 if ($showfield) {
2079 if ($value == 'country') {
2080 print '<td class="liste_titre">';
2081 print $form->select_country($search_country_id, 'search_country_id', '', 28, 'minwidth100 maxwidth150 maxwidthonsmartphone', '', '&nbsp;');
2082 print '</td>';
2083 $colspan++;
2084 } elseif ($value == 'code') {
2085 print '<td class="liste_titre">';
2086 print '<input type="text" class="maxwidth100" name="search_code" value="'.dol_escape_htmltag($search_code).'">';
2087 print '</td>';
2088 $colspan++;
2089 } elseif ($value == 'type_vat') {
2090 print '<td class="liste_titre">';
2091 print $form->selectarray('search_'.$value, $type_vatList, (empty($obj->{$value}) ? '' : $obj->{$value}), 1);
2092 print '</td>';
2093 $colspan++;
2094 } else {
2095 print '<td class="liste_titre">';
2096 print '</td>';
2097 $colspan++;
2098 }
2099 }
2100 }
2101 if ($id == DICT_COUNTRY) {
2102 print '<td></td>';
2103 $colspan++;
2104 print '<td></td>';
2105 $colspan++;
2106 print '<td></td>';
2107 $colspan++;
2108 }
2109
2110 // Active
2111 print '<td class="liste_titre center parentonrightofpage">';
2112 print $form->selectyesno('search_active', $search_active, 0, false, 1, 1, 'maxwidth100 onrightofpage', 'Activated', 'Disabled');
2113 print '</td>';
2114 $colspan++;
2115
2116 // Action button
2117 if (!$conf->main_checkbox_left_column) {
2118 print '<td class="liste_titre center maxwidthsearch">';
2119 if ($filterfound) {
2120 $searchpicto = $form->showFilterAndCheckAddButtons(0);
2121 print $searchpicto;
2122 }
2123 print '</td>';
2124 $colspan++;
2125 }
2126
2127 print '</tr>';
2128
2129
2130 // Title of lines
2131 print '<!-- line title of record -->'."\n";
2132 print '<tr class="liste_titre">';
2133
2134 // Action button
2135 if ($conf->main_checkbox_left_column) {
2136 print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', ($page ? 'page='.$page.'&' : ''), $param, '', $sortfield, $sortorder, 'center maxwidthsearch ');
2137 }
2138
2139 foreach ($fieldlist as $field => $value) {
2140 if ($value == 'entity') {
2141 continue;
2142 }
2143
2144 if (in_array($value, array('label', 'libelle', 'libelle_facture')) && empty($tabcomplete[$tabname[$id]]['help'][$value])) {
2145 if (!isset($tabcomplete[$tabname[$id]]['help']) || !is_array($tabcomplete[$tabname[$id]]['help'])) { // protection when $tabcomplete[$tabname[$id]]['help'] is a an empty string, we must force it into an array
2146 $tabcomplete[$tabname[$id]]['help'] = array();
2147 }
2148 $tabcomplete[$tabname[$id]]['help'][$value] = $langs->trans('LabelUsedByDefault');
2149 }
2150
2151 // Determines the name of the field in relation to the possible names
2152 // in data dictionaries
2153 $showfield = 1; // By default
2154 $cssprefix = '';
2155 $sortable = 1;
2156 $valuetoshow = dictFieldLabel($value, $tabname[$id], $tablib[$id]); // Label of the column
2157
2158 // Special cases for the CSS of the column or to disable the sort
2159 if ($value == 'taux') {
2160 $cssprefix = 'center ';
2161 }
2162 if (in_array($value, array('type_vat', 'localtax1_type', 'localtax1', 'localtax2_type', 'localtax2'))) {
2163 $cssprefix = "center minwidth75 ";
2164 $sortable = 0;
2165 }
2166 if (in_array($value, array('pos', 'position', 'deposit_percent', 'nbjour', 'decalage'))) {
2167 $cssprefix = 'right ';
2168 }
2169 if ($value == 'recuperableonly') {
2170 $cssprefix = "center ";
2171 }
2172 if ($value == 'einvoice_vatex') {
2173 $cssprefix = "center";
2174 }
2175 if ($value == 'type_cdr') {
2176 $cssprefix = "center ";
2177 }
2178 if ($value == 'accountancy_code_sell' || $value == 'accountancy_code_buy') {
2179 $sortable = 0;
2180 }
2181 if (in_array($value, array('sortorder', 'fk_parent', 'use_default'))) {
2182 $cssprefix = 'center ';
2183 }
2184 if ($value == 'public' && $tablib[$id] == 'TicketDictCategory') {
2185 $cssprefix = 'center ';
2186 }
2187
2188 if ($value == 'region_id' || $value == 'country_id' || $value == 'department_buyer_id') {
2189 $showfield = 0;
2190 }
2191 if (empty($arrayfields[$value]['checked'])) {
2192 $showfield = 0; // Column was not selected to be displayed
2193 }
2194
2195 // Show field title
2196 if ($showfield) {
2197 $tooltiphelp = (isset($tabcomplete[$tabname[$id]]['help'][$value]) ? $tabcomplete[$tabname[$id]]['help'][$value] : '');
2198
2199 if ($tooltiphelp && preg_match('/^http(s*):/i', $tooltiphelp)) {
2200 $newvaluetoshow = '<a href="'.$tooltiphelp.'" target="_blank">'.$valuetoshow.' '.img_help(1, $valuetoshow).'</a>';
2201 } elseif ($tooltiphelp) {
2202 $newvaluetoshow = $form->textwithpicto($valuetoshow, $tooltiphelp);
2203 } else {
2204 $newvaluetoshow = $valuetoshow;
2205 }
2206
2207 print getTitleFieldOfList($newvaluetoshow, 0, $_SERVER["PHP_SELF"], ($sortable ? $value : ''), ($page ? 'page='.$page.'&' : ''), $param, '', $sortfield, $sortorder, $cssprefix);
2208 }
2209 }
2210 // Favorite, EEC & Sepa - Only activated on country dictionary
2211 if ($id == DICT_COUNTRY) {
2212 print getTitleFieldOfList($langs->trans("InEEC"), 0, $_SERVER["PHP_SELF"], "eec", ($page ? 'page='.$page.'&' : ''), $param, '', $sortfield, $sortorder, 'center ', 0, $langs->trans("CountryIsInEEC"));
2213 print getTitleFieldOfList($langs->trans("InSepa"), 0, $_SERVER["PHP_SELF"], "sepa", ($page ? 'page='.$page.'&' : ''), $param, '', $sortfield, $sortorder, 'center ', 0, $langs->trans("CountryIsInSepa"));
2214 print getTitleFieldOfList($langs->trans("Favorite"), 0, $_SERVER["PHP_SELF"], "favorite", ($page ? 'page='.$page.'&' : ''), $param, '', $sortfield, $sortorder, 'center ');
2215 }
2216
2217 // Status
2218 print getTitleFieldOfList($langs->trans("Status"), 0, $_SERVER["PHP_SELF"], "active", ($page ? 'page='.$page.'&' : ''), $param, '', $sortfield, $sortorder, 'center ');
2219
2220 // Action button
2221 if (!$conf->main_checkbox_left_column) {
2222 print getTitleFieldOfList($selectedfields);
2223 }
2224 print '</tr>';
2225
2226
2227 // Lines with values
2228 if ($num) {
2229 print '<!-- lines of dict -->'."\n";
2230 while ($i < $num) {
2231 $obj = $db->fetch_object($resql);
2232
2233 // Entity owning this row, when the dictionary is entity aware (the SELECT of
2234 // $tabsql must then include the entity column). It is used to target the right row
2235 // on write, and to tell rows of another entity apart just below.
2236 $withentity = (isset($obj->entity) ? (int) $obj->entity : null);
2237
2238 // We discard empty lines
2239 if ($id == DICT_COUNTRY) {
2240 if ($obj->code == '') {
2241 $i++;
2242 continue;
2243 }
2244 }
2245
2246 // Can an entry be erased, disabled or modified ? (true by default)
2247 $iserasable = 1;
2248 $canbedisabled = 1;
2249 $canbemodified = 1;
2250 if (isset($obj->code) && !in_array($id, array(DICT_TVA, DICT_PRODUCT_NATURE))) {
2251 if (($obj->code == '0' || $obj->code == '' || preg_match('/unknown/i', $obj->code))) {
2252 $iserasable = 0;
2253 $canbedisabled = 0;
2254 } elseif ($obj->code == 'RECEP') {
2255 $iserasable = 0;
2256 $canbedisabled = 0;
2257 } elseif ($obj->code == 'EF0') {
2258 $iserasable = 0;
2259 $canbedisabled = 0;
2260 }
2261 }
2262 if ($id == DICT_TYPE_CONTAINER && $obj->module == 'system') {
2263 $iserasable = 0;
2264 $canbedisabled = 0;
2265 if (in_array($obj->code, array('banner'))) {
2266 $canbedisabled = 1;
2267 }
2268 }
2269 if (isset($obj->type) && in_array($obj->type, array('system', 'systemauto'))) {
2270 $iserasable = 0;
2271 }
2272 if (in_array(empty($obj->code) ? '' : $obj->code, array('AC_OTH', 'AC_OTH_AUTO')) || in_array(empty($obj->type) ? '' : $obj->type, array('systemauto'))) {
2273 $canbedisabled = 0;
2274 $canbedisabled = 0;
2275 }
2276 $canbemodified = $iserasable;
2277
2278 if (!empty($obj->code) && $obj->code == 'RECEP') {
2279 $canbemodified = 1;
2280 }
2281 if ($tabname[$id] == "c_actioncomm") {
2282 $canbemodified = 1;
2283 }
2284
2285 if ($tabname[$id] == "c_product_nature" && in_array($obj->code, array(0, 1))) {
2286 $canbedisabled = 0;
2287 $canbemodified = 0;
2288 $iserasable = 0;
2289 }
2290
2291 // A row owned by another entity is read-only here. This happens when a dictionary
2292 // is shared with the current entity (for instance the dictionary of the master
2293 // entity that this entity only extends, with module multicompany): the row is
2294 // legitimately listed, but editing it would change it for the other entity too.
2295 // Without multicompany, getEntity() returns the current entity and every listed row
2296 // belongs to it, so this never triggers.
2297 if (!is_null($withentity) && $withentity != (int) getEntity($tabname[$id], 0)) {
2298 $iserasable = 0;
2299 $canbedisabled = 0;
2300 $canbemodified = 0;
2301 }
2302 // Build Url. The table is id=, the id of line is rowid=
2303 $rowidcol = empty($tabrowid[$id]) ? 'rowid' : $tabrowid[$id];
2304 // If rowidcol not defined
2305 if (empty($rowidcol) || in_array($id, array(DICT_ACTIONCOMM, DICT_CHARGESOCIALES, DICT_TYPENT, DICT_PAIEMENT, DICT_TYPE_FEES, DICT_EFFECTIF, DICT_STCOMM, DICT_HRM_PUBLIC_HOLIDAY))) {
2306 $rowidcol = 'rowid';
2307 }
2308 $url = $_SERVER["PHP_SELF"].'?'.($page ? 'page='.$page.'&' : '').'sortfield='.urlencode($sortfield).'&sortorder='.urlencode($sortorder);
2309 $url .= '&rowid='.(isset($obj->$rowidcol) ? ((int) $obj->$rowidcol) : (!empty($obj->code) ? urlencode($obj->code) : ''));
2310 $url .= '&code='.(!empty($obj->code) ? urlencode($obj->code) : '');
2311 if (!empty($param)) {
2312 $url .= '&'.$param;
2313 }
2314 // If dictionary is different for each entity
2315 if (!is_null($withentity)) {
2316 $url .= '&entity='.((int) $withentity);
2317 }
2318 $url .= '&';
2319
2320
2321 //print_r($obj);
2322 print '<tr class="oddeven" id="rowid-'.(empty($obj->rowid) ? '' : $obj->rowid).'">';
2323
2324 // Action button
2325 if ($conf->main_checkbox_left_column) {
2326 print '<td class="center maxwidthsearch nowraponall">';
2327 // Modify link
2328 if ($canbemodified) {
2329 print '<a class="reposition editfielda marginleftonly paddingleft marginrightonly paddingright" href="'.$url.'action=edit&token='.newToken().'">'.img_edit().'</a>';
2330 }
2331 // Delete link
2332 if ($iserasable) {
2333 if ($user->admin) {
2334 print '<a class="reposition marginleftonly paddingleft marginrightonly paddingright" href="'.$url.'action=delete&token='.newToken().'">'.img_delete().'</a>';
2335 }
2336 }
2337 print '</td>';
2338 }
2339
2340 // Use isset() rather than !empty() so a dictionary row with rowid = 0
2341 // (for example ST_NEVER in llx_c_stcomm) is treated as a real rowid and
2342 // not fallen back to the code, which would make it un-editable (#38781).
2343 if ($action == 'edit' && ($rowid == (isset($obj->rowid) ? $obj->rowid : $obj->code))) {
2344 $tmpaction = 'edit';
2345 $parameters = array('fieldlist' => $fieldlist, 'tabname' => $tabname[$id]);
2346 $reshook = $hookmanager->executeHooks('editDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
2347 $error = $hookmanager->error;
2348 $errors = $hookmanager->errors;
2349
2350 // Show fields
2351 if (empty($reshook)) {
2352 $withentity = dictFieldList($fieldlist, $obj, $tabname[$id], 'edit');
2353 }
2354
2355 print '<td colspan="3" class="center">';
2356 print '<div name="'.(isset($obj->rowid) ? $obj->rowid : $obj->code).'"></div>';
2357 print '<input type="hidden" name="page" value="'.((int) $page).'">';
2358 print '<input type="hidden" name="rowid" value="'.dol_escape_htmltag($rowid).'">';
2359 if (!is_null($withentity)) {
2360 print '<input type="hidden" name="entity" value="'.$withentity.'">';
2361 }
2362 print '<input type="submit" class="button button-edit smallpaddingimp" name="actionmodify" value="'.$langs->trans("Modify").'">';
2363 print '<input type="submit" class="button button-cancel smallpaddingimp" name="actioncancel" value="'.$langs->trans("Cancel").'">';
2364 print '</td>';
2365 } else {
2366 $tmpaction = 'view';
2367 $parameters = array('fieldlist' => $fieldlist, 'tabname' => $tabname[$id]);
2368 $reshook = $hookmanager->executeHooks('viewDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
2369
2370 $error = $hookmanager->error;
2371 $errors = $hookmanager->errors;
2372
2373 $langs->loadLangs(array("bills", "agenda", "propal"));
2374
2375 if (empty($reshook)) {
2376 $withentity = null;
2377 $TDurationTypes = $form->getDurationTypes($langs);
2378
2379 foreach ($fieldlist as $field => $value) {
2380 $class = (isset($tabcomplete[$tabname[$id]]['css'][$value]) ? $tabcomplete[$tabname[$id]]['css'][$value] : '');
2381 $showfield = 1;
2382 if (empty($arrayfields[$value]['checked'])) {
2383 $showfield = 0; // Column was not selected to be displayed
2384 }
2385 $valuetoshow = (isset($obj->$value) && $obj->$value !== '') ? $obj->$value : '';
2386 $titletoshow = '';
2387
2388 if ($value == 'entity') {
2389 $withentity = $valuetoshow;
2390 continue;
2391 }
2392
2393 // Management of several special cases and exceptions
2394 if ($value == 'code' && $id == DICT_PRODUCT_NATURE) {
2395 $valuetoshow = (int) $valuetoshow;
2396 } elseif ($value == 'element') {
2397 $valuetoshow = isset($elementList[$valuetoshow]) ? $elementList[$valuetoshow] : $valuetoshow;
2398 } elseif ($value == 'source') {
2399 $valuetoshow = isset($sourceList[$valuetoshow]) ? $sourceList[$valuetoshow] : $valuetoshow;
2400 } elseif ($valuetoshow == 'all') {
2401 $valuetoshow = $langs->trans('All');
2402 } elseif ($value == 'country') {
2403 if (empty($obj->country_code)) {
2404 $valuetoshow = '-';
2405 } else {
2406 $key = $langs->trans("Country".strtoupper($obj->country_code));
2407 $valuetoshow = ($key != "Country".strtoupper($obj->country_code) ? $obj->country_code." - ".$key : $obj->country);
2408 }
2409 } elseif ($value == 'recuperableonly' || $value == 'deductible' || $value == 'category_type') {
2410 $valuetoshow = yn($valuetoshow ? 1 : 0);
2411 $class = "center";
2412 } elseif ($value == 'type_cdr') {
2413 if (empty($valuetoshow)) {
2414 $valuetoshow = $langs->trans('None');
2415 } elseif ($valuetoshow == 1) {
2416 $valuetoshow = $langs->trans('AtEndOfMonth');
2417 } elseif ($valuetoshow == 2) {
2418 $valuetoshow = $langs->trans('CurrentNext');
2419 }
2420 $class = "center tdoverflowmax125";
2421 } elseif ($value == 'price' || preg_match('/^amount/i', $value)) {
2422 $valuetoshow = price($valuetoshow);
2423 }
2424 if (in_array($value, array('private', 'joinfile', 'use_default'))) {
2425 if (!empty($valuetoshow)) {
2426 $valuetoshow = img_picto('', 'tick');
2427 } else {
2428 $valuetoshow = '';
2429 }
2430 } elseif ($value == 'libelle_facture') {
2431 $key = $langs->trans("PaymentCondition".strtoupper($obj->code));
2432 $valuetoshow = ($obj->code && $key != "PaymentCondition".strtoupper($obj->code) ? $key : $obj->$value);
2433 $valuetoshow = nl2br($valuetoshow);
2434 $titletoshow = $valuetoshow;
2435 $class = 'small tdoverflowmax200';
2436 } elseif ($value == 'label' && $tabname[$id] == 'c_country') {
2437 $key = $langs->trans("Country".strtoupper($obj->code));
2438 $valuetoshow = ($obj->code && $key != "Country".strtoupper($obj->code) ? $key : $obj->$value);
2439 } elseif ($value == 'label' && $tabname[$id] == 'c_availability') {
2440 $key = $langs->trans("AvailabilityType".strtoupper($obj->code));
2441 $valuetoshow = ($obj->code && $key != "AvailabilityType".strtoupper($obj->code) ? $key : $obj->$value);
2442 } elseif ($value == 'libelle' && $tabname[$id] == 'c_actioncomm') {
2443 $key = $langs->trans("Action".strtoupper($obj->code));
2444 $valuetoshow = ($obj->code && $key != "Action".strtoupper($obj->code) ? $key : $obj->$value);
2445 } elseif (!empty($obj->code_iso) && $value == 'label' && $tabname[$id] == 'c_currencies') {
2446 $key = $langs->trans("Currency".strtoupper($obj->code_iso));
2447 $valuetoshow = (/* $obj->code_iso && */ $key != "Currency".strtoupper($obj->code_iso) ? $key : $obj->$value);
2448 } elseif ($value == 'libelle' && $tabname[$id] == 'c_typent') {
2449 $key = $langs->trans(strtoupper($obj->code));
2450 $valuetoshow = ($key != strtoupper($obj->code) ? $key : $obj->$value);
2451 } elseif ($value == 'libelle' && $tabname[$id] == 'c_prospectlevel') {
2452 $key = $langs->trans(strtoupper($obj->code));
2453 $valuetoshow = ($key != strtoupper($obj->code) ? $key : $obj->$value);
2454 } elseif ($value == 'label' && $tabname[$id] == 'c_civility') {
2455 $key = $langs->trans("Civility".strtoupper($obj->code));
2456 $valuetoshow = ($obj->code && $key != "Civility".strtoupper($obj->code) ? $key : $obj->$value);
2457 } elseif ($value == 'libelle' && $tabname[$id] == 'c_type_contact') {
2458 $key = $langs->trans("TypeContact_".$obj->element."_".$obj->source."_".strtoupper($obj->code));
2459 $valuetoshow = ($obj->code && $key != "TypeContact_".$obj->element."_".$obj->source."_".strtoupper($obj->code) ? $key : $obj->$value);
2460 } elseif ($value == 'libelle' && $tabname[$id] == 'c_payment_term') {
2461 $key = $langs->trans("PaymentConditionShort".strtoupper($obj->code));
2462 $valuetoshow = ($obj->code && $key != "PaymentConditionShort".strtoupper($obj->code) ? $key : $obj->$value);
2463 $titletoshow = $key;
2464 $class = "tdoverflowmax150";
2465 } elseif ($value == 'libelle' && $tabname[$id] == 'c_paiement') {
2466 $key = $langs->trans("PaymentType".strtoupper($obj->code));
2467 $valuetoshow = $obj->$value;
2468 if ($obj->code && array_key_exists("PaymentType".strtoupper($obj->code), $langs->tab_translate)) {
2469 $htmltext = $form->textwithpicto($langs->trans("TranslationFound").': '.$key, $langs->trans("TheTranslationIsSearchedFromKey", "PaymentType".strtoupper($obj->code)));
2470 } else {
2471 $htmltext = $form->textwithpicto($langs->trans("TranslationFound").': '.$langs->trans("No"), $langs->trans("TheTranslationIsSearchedFromKey", "PaymentType".strtoupper($obj->code)));
2472 }
2473 //$valuetoshow = $form->textwithpicto($valuetoshow, $htmltext);
2474 $valuetoshow .= '<br><span class="opacitymedium small">'.$htmltext.'</span>';
2475 } elseif ($value == 'type' && $tabname[$id] == 'c_paiement') {
2476 $payment_type_list = array(0 => $langs->trans('PaymentTypeCustomer'), 1 => $langs->trans('PaymentTypeSupplier'), 2 => $langs->trans('PaymentTypeBoth'));
2477 $valuetoshow = $payment_type_list[$valuetoshow];
2478 } elseif ($value == 'label' && $tabname[$id] == 'c_input_reason') {
2479 $key = $langs->trans("DemandReasonType".strtoupper($obj->code));
2480 $valuetoshow = ($obj->code && $key != "DemandReasonType".strtoupper($obj->code) ? $key : $obj->$value);
2481 } elseif ($value == 'libelle' && $tabname[$id] == 'c_input_method') {
2482 $langs->load("orders");
2483 $key = $langs->trans($obj->code);
2484 $valuetoshow = ($obj->code && $key != $obj->code) ? $key : $obj->$value;
2485 } elseif ($value == 'libelle' && $tabname[$id] == 'c_shipment_mode') {
2486 $langs->load("sendings");
2487 $key = $langs->trans("SendingMethod".strtoupper($obj->code));
2488 $valuetoshow = ($obj->code && $key != "SendingMethod".strtoupper($obj->code) ? $key : $obj->$value);
2489 } elseif ($value == 'libelle' && $tabname[$id] == 'c_paper_format') {
2490 $key = $langs->trans('PaperFormat'.strtoupper($obj->code));
2491 $valuetoshow = ($obj->code && $key != 'PaperFormat'.strtoupper($obj->code) ? $key : $obj->$value);
2492 } elseif ($value == 'label' && $tabname[$id] == 'c_type_fees') {
2493 $langs->load('trips');
2494 $key = $langs->trans(strtoupper($obj->code));
2495 $valuetoshow = ($obj->code && $key != strtoupper($obj->code) ? $key : $obj->$value);
2496 } elseif ($value == 'region_id' || $value == 'country_id' || $value == 'department_buyer_id') {
2497 $showfield = 0;
2498 } elseif ($value == 'unicode') {
2499 $valuetoshow = $langs->getCurrencySymbol($obj->code, 1);
2500 } elseif ($value == 'label' && $tabname[GETPOSTINT("id")] == 'c_units') {
2501 $langs->load("products");
2502 $valuetoshow = $langs->trans($obj->$value);
2503 } elseif ($value == 'short_label' && $tabname[GETPOSTINT("id")] == 'c_units') {
2504 $langs->load("products");
2505 $valuetoshow = $langs->trans($obj->$value);
2506 } elseif (($value == 'unit') && ($tabname[$id] == 'c_paper_format')) {
2507 $key = $langs->trans('SizeUnit'.strtolower($obj->unit));
2508 $valuetoshow = ($obj->code && $key != 'SizeUnit'.strtolower($obj->unit) ? $key : $obj->$value);
2509 } elseif ($value == 'localtax1' || $value == 'localtax2') {
2510 $class = "center";
2511 } elseif ($value == 'type_vat') {
2512 $valuetoshow = $type_vatList[(int) $valuetoshow];
2513 $class = "center";
2514 } elseif ($value == 'localtax1_type') {
2515 if ($obj->localtax1 != 0) {
2516 $valuetoshow = $localtax_typeList[$valuetoshow];
2517 } else {
2518 $valuetoshow = '';
2519 }
2520 $class = "center";
2521 } elseif ($value == 'localtax2_type') {
2522 if ($obj->localtax2 != 0) {
2523 $valuetoshow = $localtax_typeList[$valuetoshow];
2524 } else {
2525 $valuetoshow = '';
2526 }
2527 $class = "center";
2528 } elseif ($value == 'taux') {
2529 $valuetoshow = price($valuetoshow, 0, $langs, 0, 0);
2530 $class = "center";
2531 } elseif (in_array($value, array('recuperableonly'))) {
2532 $class = "center";
2533 } elseif ($value == 'accountancy_code' || $value == 'accountancy_code_sell' || $value == 'accountancy_code_buy') {
2534 if (isModEnabled('accounting')) {
2535 require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php';
2536 $tmpaccountingaccount = new AccountingAccount($db);
2537 $tmpaccountingaccount->fetch(0, $valuetoshow, 1);
2538 $titletoshow = $langs->transnoentitiesnoconv("Pcgtype").': '.$tmpaccountingaccount->pcg_type;
2539 }
2540 $valuetoshow = length_accountg($valuetoshow);
2541 } elseif ($value == 'fk_tva') {
2542 if (empty($form->cache_vatrates)) {
2543 $form->load_tva('cache_fk_tva', '', $mysoc, new Societe($db), 0, 0, '', false, -1);
2544 }
2545 foreach ($form->cache_vatrates as $key => $Tab) {
2546 if ($form->cache_vatrates[$key]['rowid'] == $valuetoshow) {
2547 $valuetoshow = $form->cache_vatrates[$key]['label'];
2548 break;
2549 }
2550 }
2551 } elseif ($value == 'fk_c_exp_tax_cat') {
2552 $tmpid = $valuetoshow;
2553 $valuetoshow = getDictionaryValue('c_exp_tax_cat', 'label', $tmpid);
2554 $valuetoshow = $langs->trans($valuetoshow ? $valuetoshow : $tmpid);
2555 } elseif ($tabname[$id] == 'c_exp_tax_cat') {
2556 $valuetoshow = $langs->trans($valuetoshow);
2557 } elseif ($value == 'libelle' && ($tabname[$id] == 'c_stcomm' || $tabname[$id] == 'c_stcommcontact')) {
2558 $key = 'StatusProspect'.$obj->rowid;
2559 $trans = $langs->trans($key);
2560 $valuetoshow = ($trans != $key ? $trans : $obj->{$value});
2561 } elseif ($value == 'label' && $tabname[$id] == 'c_units') {
2562 $langs->load('other');
2563 $key = $langs->trans($obj->label);
2564 $valuetoshow = ($obj->label && $key != strtoupper($obj->label) ? $key : $obj->{$value});
2565 } elseif ($value == 'label' && $tabname[$id] == 'c_product_nature') {
2566 $langs->load("products");
2567 $valuetoshow = $langs->trans($obj->{$value});
2568 } elseif ($fieldlist[$field] == 'label' && $tabname[$id] == 'c_productbatch_qcstatus') {
2569 $langs->load("productbatch");
2570 $valuetoshow = $langs->trans($obj->{$value});
2571 } elseif ($value == 'block_if_negative') {
2572 $valuetoshow = yn($obj->{$value});
2573 } elseif ($value == 'icon') {
2574 $valuetoshow = $obj->{$value}." ".img_picto("", preg_replace('/^fa-/', '', $obj->{$value}));
2575 } elseif ($value == 'type_duration') {
2576 if (!empty($obj->{$value}) && array_key_exists($obj->{$value}, $TDurationTypes)) {
2577 $valuetoshow = $TDurationTypes[$obj->{$value}];
2578 }
2579 } elseif (in_array($value, array('leftmargin', 'topmargin', 'spacex', 'spacey', 'width', 'height', 'custom_x', 'custom_y'))) {
2580 $valuetoshow = price2num($valuetoshow);
2581 } elseif ($value == 'type' && $id == DICT_ACTIONCOMM && !empty($obj->module)) {
2582 $titletoshow = $langs->trans("Module").' '.$obj->module;
2583 } elseif ($value == 'color') {
2584 $valuetoshow = $formother->showColor($obj->{$value}, '');
2585 }
2586
2587
2588 // Now we define the CSS
2589 $class .= ($class ? ' ' : '').'tddict';
2590 if ($value == 'name') {
2591 $class .= ' tdoverflowmax200';
2592 }
2593 if ($value == 'note' && $id == DICT_TVA) {
2594 $class .= ' tdoverflowmax200';
2595 }
2596 if (in_array($value, array($value == 'tracking'))) {
2597 $class .= ' tdoverflowauto';
2598 }
2599 if (in_array($value, array('nbjour', 'decalage', 'pos', 'position', 'deposit_percent'))) {
2600 $class .= ' right';
2601 }
2602 if (in_array($value, array('icon', 'type_vat', 'localtax1_type', 'localtax2_type'))) {
2603 $class .= ' nowraponall';
2604 }
2605 if (in_array($value, array('use_default', 'fk_parent', 'sortorder', 'public'))) {
2606 $class .= ' center';
2607 }
2608 if (in_array($value, array('localtax1_type', 'localtax2_type', 'note', 'note_public', 'note_private'))) {
2609 $class .= ' small';
2610 }
2611
2612 // Add val as tooltip if there is a tdoverflow on the cell
2613 if (empty($titletoshow) && preg_match('/tdoverflow/', $class)) {
2614 $titletoshow = $valuetoshow;
2615 }
2616
2617 // Show value for field
2618 if ($showfield) {
2619 print '<!-- field value '. $value .' --><td class="'.$class.'"'.($titletoshow ? ' title="'.dolPrintHTMLForAttribute($titletoshow).'"' : '').'>'.$valuetoshow.'</td>';
2620 }
2621 }
2622
2623 // Favorite, EEC & Sepa
2624 // Only for country dictionary
2625 if ($id == DICT_COUNTRY) {
2626 print '<td class="nowraponall center">';
2627 // Is in EEC
2628 if ($iserasable) {
2629 print '<a class="reposition" href="'.$url.'action='.$acts[$obj->eec].'_eec&token='.newToken().'">'.$actl[$obj->eec].'</a>';
2630 } else {
2631 print '<span class="opacitymedium">'.$langs->trans("AlwaysActive").'</span>';
2632 }
2633 print '</td>';
2634 print '<td class="nowraponall center">';
2635 // Is in Sepa
2636 if ($iserasable) {
2637 print '<a class="reposition" href="'.$url.'action='.$acts[$obj->sepa].'_sepa&token='.newToken().'">'.$actl[$obj->sepa].'</a>';
2638 } else {
2639 print '<span class="opacitymedium">'.$langs->trans("AlwaysActive").'</span>';
2640 }
2641 print '</td>';
2642 print '<td class="nowraponall center">';
2643 // Favorite
2644 if ($iserasable) {
2645 print '<a class="reposition" href="'.$url.'action='.$acts[$obj->favorite].'_favorite&token='.newToken().'">'.$actl[$obj->favorite].'</a>';
2646 } else {
2647 print '<span class="opacitymedium">'.$langs->trans("AlwaysActive").'</span>';
2648 }
2649 print '</td>';
2650 }
2651 }
2652
2653 // Active
2654 print '<td class="nowraponall center">';
2655 if ($canbedisabled) {
2656 print '<a class="reposition" href="'.$url.'action='.$acts[$obj->active].'&token='.newToken().'">'.$actl[$obj->active].'</a>';
2657 } else {
2658 if (in_array($obj->code, array('AC_OTH', 'AC_OTH_AUTO'))) {
2659 print $langs->trans("AlwaysActive");
2660 } elseif (isset($obj->type) && in_array($obj->type, array('systemauto')) && empty($obj->active)) {
2661 print $langs->trans("Deprecated");
2662 } elseif (isset($obj->type) && in_array($obj->type, array('system')) && !empty($obj->active) && $obj->code != 'AC_OTH') {
2663 print $langs->trans("UsedOnlyWithTypeOption");
2664 } else {
2665 print '<span class="opacitymedium">'.$langs->trans("AlwaysActive").'</span>';
2666 }
2667 }
2668 print "</td>";
2669
2670 // Action button
2671 if (!$conf->main_checkbox_left_column) {
2672 print '<td class="center maxwidthsearch nowraponall">';
2673 // Modify link
2674 if ($canbemodified) {
2675 print '<a class="reposition marginleftonly paddingleft marginrightonly paddingright editfielda" href="'.$url.'action=edit&token='.newToken().'">'.img_edit().'</a>';
2676 }
2677 // Delete link
2678 if ($iserasable) {
2679 if ($user->admin) {
2680 print '<a class="reposition marginleftonly paddingleft marginrightonly paddingright" href="'.$url.'action=delete&token='.newToken().'">'.img_delete().'</a>';
2681 }
2682 }
2683 print '</td>';
2684 }
2685
2686 print "</tr>\n";
2687 }
2688 $i++;
2689 }
2690 } else {
2691 print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
2692 }
2693
2694 print '</table>';
2695 print '</div>';
2696 } else {
2697 dol_print_error($db);
2698 }
2699
2700 print '</form>';
2701} else {
2702 /*
2703 * Show list of dictionary to show
2704 */
2705 print load_fiche_titre($title, $linkback, $titlepicto);
2706
2707 print '<span class="opacitymedium">'.$langs->trans("DictionaryDesc");
2708 print " ".$langs->trans("OnlyActiveElementsAreShown")."<br>\n";
2709 print '</span><br>';
2710 print "<br>\n";
2711
2712 $lastlineisempty = false;
2713
2714 print '<div class="div-table-responsive-no-min">';
2715 print '<table class="noborder centpercent">';
2716 print '<tr class="liste_titre">';
2717 print '<td>'.$langs->trans("Dictionary").'</td>';
2718 print '<td></td>';
2719 print '<td class="hideonsmartphone"></td>';
2720 print '</tr>';
2721
2722 $showemptyline = '';
2723 foreach ($taborder as $i) {
2724 if (isset($tabname[$i]) && empty($tabcond[$i])) {
2725 continue;
2726 }
2727
2728 if ($i) {
2729 if ($showemptyline) {
2730 print '<tr class="oddeven"><td></td><td></td><td class="hideonsmartphone"></td></tr>';
2731 $showemptyline = 0;
2732 }
2733
2734
2735 $value = $tabname[$i];
2736 print '<tr class="oddeven"><td class="minwidth200">';
2737 if (!empty($tabcond[$i])) {
2738 $tabnamenoprefix = preg_replace('/'.MAIN_DB_PREFIX.'/', '', $tabname[$i]);
2739 print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$i;
2740 if ($i == DICT_CHARGESOCIALES) {
2741 print '&search_country_id='.$mysoc->country_id;
2742 }
2743 print '">';
2744 if (!empty($tabcomplete[$tabnamenoprefix]['picto'])) {
2745 print img_picto('', $tabcomplete[$tabnamenoprefix]['picto'], 'class="pictofixedwidth paddingrightonly"');
2746 }
2747 print $langs->trans($tablib[$i]);
2748 print '</a>';
2749 } else {
2750 print $langs->trans($tablib[$i]);
2751 }
2752 print '</td>';
2753 print '<td>';
2754 print '<a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?id='.$i.'">';
2755 print img_picto('Edit', 'edit', '');
2756 print '</a>';
2757 print '</td>';
2758 print '<td class="right hideonsmartphone">';
2759 print $form->textwithpicto('', $langs->trans("Table").': '.MAIN_DB_PREFIX.$tabname[$i]);
2760 print '</td>';
2761 print '</tr>';
2762 $lastlineisempty = false;
2763 } else {
2764 if (!$lastlineisempty) {
2765 $showemptyline = 1;
2766 $lastlineisempty = true;
2767 }
2768 }
2769 }
2770 print '</table>';
2771 print '</div>';
2772}
2773
2774print '<br>';
2775if (GETPOST('id') && GETPOST('id') == DICT_SOCIALNETWORKS) {
2776 print dol_get_fiche_end();
2777}
2778// End of page
2779llxFooter();
2780$db->close();
2781
2782
2791function dictFieldLabel($value, $tabname = '', $tablib = '')
2792{
2793 global $langs;
2794
2795 $valuetoshow = ucfirst($value); // By default
2796 $valuetoshow = $langs->trans($valuetoshow); // try to translate
2797
2798 // Special cases
2799 if ($value == 'source') {
2800 $valuetoshow = $langs->trans("Contact");
2801 }
2802 if ($value == 'price') {
2803 $valuetoshow = $langs->trans("PriceUHT");
2804 }
2805 if ($value == 'taux') {
2806 if ($tabname != "c_revenuestamp") {
2807 $valuetoshow = $langs->trans("Rate");
2808 } else {
2809 $valuetoshow = $langs->trans("Amount");
2810 }
2811 }
2812 if ($value == 'type_vat') {
2813 $valuetoshow = $langs->trans("VATType");
2814 }
2815 if ($value == 'localtax1_type') {
2816 $valuetoshow = $langs->trans("UseLocalTax")." 2";
2817 }
2818 if ($value == 'localtax1') {
2819 $valuetoshow = $langs->trans("RateOfTaxN", '2');
2820 }
2821 if ($value == 'localtax2_type') {
2822 $valuetoshow = $langs->trans("UseLocalTax")." 3";
2823 }
2824 if ($value == 'localtax2') {
2825 $valuetoshow = $langs->trans("RateOfTaxN", '3');
2826 }
2827 if ($value == 'organization') {
2828 $valuetoshow = $langs->trans("Organization");
2829 }
2830 if ($value == 'lang') {
2831 $valuetoshow = $langs->trans("Language");
2832 }
2833 if ($value == 'type') {
2834 $valuetoshow = $langs->trans("Type");
2835 }
2836 if ($value == 'code') {
2837 $valuetoshow = $langs->trans("Code");
2838 }
2839 if (in_array($value, array('pos', 'position'))) {
2840 $valuetoshow = $langs->trans("Position");
2841 }
2842 if ($value == 'libelle' || $value == 'label') {
2843 $valuetoshow = $langs->trans("Label");
2844 }
2845 if ($value == 'libelle_facture') {
2846 $valuetoshow = $langs->trans("LabelOnDocuments");
2847 }
2848 if ($value == 'deposit_percent') {
2849 $valuetoshow = $langs->trans('DepositPercent');
2850 }
2851 if ($value == 'country') {
2852 $valuetoshow = $langs->trans("Country");
2853 }
2854 if ($value == 'phone_code') {
2855 $valuetoshow = $langs->trans("PhoneCode");
2856 }
2857 if ($value == 'trunk_prefix') {
2858 $valuetoshow = $langs->trans("TrunkPrefix");
2859 }
2860 if ($value == 'department_buyer') {
2861 $valuetoshow = $langs->trans('DepartmentBuyer');
2862 }
2863 if ($value == 'recuperableonly') {
2864 $valuetoshow = $langs->trans("NPR");
2865 }
2866 if ($value == 'einvoice_vatex') {
2867 $valuetoshow = $langs->trans("VATExemptionCode");
2868 }
2869 if ($value == 'nbjour') {
2870 $valuetoshow = $langs->trans("NbOfDays");
2871 }
2872 if ($value == 'type_cdr') {
2873 $valuetoshow = $langs->trans("AtEndOfMonth");
2874 }
2875 if ($value == 'decalage') {
2876 $valuetoshow = $langs->trans("Offset");
2877 }
2878 if ($value == 'width' || $value == 'nx') {
2879 $valuetoshow = $langs->trans("Width");
2880 }
2881 if ($value == 'height' || $value == 'ny') {
2882 $valuetoshow = $langs->trans("Height");
2883 }
2884 if ($value == 'unit' || $value == 'metric') {
2885 $valuetoshow = $langs->trans("MeasuringUnit");
2886 }
2887 if ($value == 'accountancy_code') {
2888 $valuetoshow = $langs->trans("AccountancyCode");
2889 }
2890 if ($value == 'accountancy_code_sell') {
2891 $valuetoshow = $langs->trans("AccountancyCodeSell");
2892 }
2893 if ($value == 'accountancy_code_buy') {
2894 $valuetoshow = $langs->trans("AccountancyCodeBuy");
2895 }
2896 if ($value == 'fk_pcg_version') {
2897 $valuetoshow = $langs->trans("Pcg_version");
2898 }
2899 if ($value == 'account_parent') {
2900 $valuetoshow = $langs->trans("Accountsparent");
2901 }
2902 if ($value == 'pcg_type') {
2903 $valuetoshow = $langs->trans("Pcg_type");
2904 }
2905 if ($value == 'pcg_subtype') {
2906 $valuetoshow = $langs->trans("Pcg_subtype");
2907 }
2908 if ($value == 'sortorder') {
2909 $valuetoshow = $langs->trans("SortOrder");
2910 }
2911 if ($value == 'short_label') {
2912 $valuetoshow = $langs->trans("ShortLabel");
2913 }
2914 if ($value == 'fk_parent') {
2915 $valuetoshow = $langs->trans("ParentID");
2916 }
2917 if ($value == 'range_account') {
2918 $valuetoshow = $langs->trans("Range");
2919 }
2920 if ($value == 'sens') {
2921 $valuetoshow = $langs->trans("Sens");
2922 }
2923 if ($value == 'category_type') {
2924 $valuetoshow = $langs->trans("Calculated");
2925 }
2926 if ($value == 'formula') {
2927 $valuetoshow = $langs->trans("Formula");
2928 }
2929 if ($value == 'paper_size') {
2930 $valuetoshow = $langs->trans("PaperSize");
2931 }
2932 if ($value == 'orientation') {
2933 $valuetoshow = $langs->trans("Orientation");
2934 }
2935 if ($value == 'leftmargin') {
2936 $valuetoshow = $langs->trans("LeftMargin");
2937 }
2938 if ($value == 'topmargin') {
2939 $valuetoshow = $langs->trans("TopMargin");
2940 }
2941 if ($value == 'spacex') {
2942 $valuetoshow = $langs->trans("SpaceX");
2943 }
2944 if ($value == 'spacey') {
2945 $valuetoshow = $langs->trans("SpaceY");
2946 }
2947 if ($value == 'font_size') {
2948 $valuetoshow = $langs->trans("FontSize");
2949 }
2950 if ($value == 'custom_x') {
2951 $valuetoshow = $langs->trans("CustomX");
2952 }
2953 if ($value == 'custom_y') {
2954 $valuetoshow = $langs->trans("CustomY");
2955 }
2956 if ($value == 'percent') {
2957 $valuetoshow = $langs->trans("Percentage");
2958 }
2959 if ($value == 'affect') {
2960 $valuetoshow = $langs->trans("WithCounter");
2961 }
2962 if ($value == 'delay') {
2963 $valuetoshow = $langs->trans("NoticePeriod");
2964 }
2965 if ($value == 'newbymonth') {
2966 $valuetoshow = $langs->trans("NewByMonth");
2967 }
2968 if ($value == 'fk_tva') {
2969 $valuetoshow = $langs->trans("VAT");
2970 }
2971 if ($value == 'range_ik') {
2972 $valuetoshow = $langs->trans("RangeIk");
2973 }
2974 if ($value == 'fk_c_exp_tax_cat') {
2975 $valuetoshow = $langs->trans("CarCategory");
2976 }
2977 if ($value == 'revenuestamp_type') {
2978 $valuetoshow = $langs->trans('TypeOfRevenueStamp');
2979 }
2980 if ($value == 'use_default') {
2981 $valuetoshow = $langs->trans('Default');
2982 }
2983 if ($value == 'unit_type') {
2984 $valuetoshow = $langs->trans('TypeOfUnit');
2985 }
2986 if ($value == 'public' && $tablib == 'TicketDictCategory') {
2987 $valuetoshow = $langs->trans('TicketGroupIsPublic');
2988 }
2989 if ($value == 'block_if_negative') {
2990 $valuetoshow = $langs->trans('BlockHolidayIfNegative');
2991 }
2992 if ($value == 'type_duration') {
2993 $valuetoshow = $langs->trans('Unit');
2994 }
2995
2996 return $valuetoshow;
2997}
2998
2999
3009function dictFieldList($fieldlist, $obj = null, $tabname = '', $context = '')
3010{
3011 global $langs, $db, $mysoc;
3012 global $form, $formother;
3013 global $region_id;
3014 global $elementList, $sourceList, $localtax_typeList, $type_vatList;
3015
3016 $formadmin = new FormAdmin($db);
3017 $formcompany = new FormCompany($db);
3018 $formaccounting = new FormAccounting($db);
3019
3020 $withentity = '';
3021
3022 foreach ($fieldlist as $field => $value) {
3023 if ($value == 'entity' && isset($obj->$value)) {
3024 $withentity = $obj->$value;
3025 continue;
3026 }
3027
3028 if (in_array($value, array('code', 'libelle', 'type')) && $tabname == "c_actioncomm" && isset($obj->$value) && in_array($obj->type, array('system', 'systemauto'))) {
3029 // Special case for c_actioncomm (field that should not be modified)
3030 $hidden = (!empty($obj->{$value}) ? $obj->{$value} : '');
3031 print '<td>';
3032 print '<input type="hidden" name="'. $value .'" value="'.$hidden.'">';
3033 print $langs->trans($hidden);
3034 print '</td>';
3035 } elseif ($value == 'country') {
3036 if (in_array('region_id', $fieldlist)) {
3037 print '<td>';
3038 print '</td>';
3039 continue;
3040 } // For state page, we do not show the country input (we link to region, not country)
3041 print '<td>';
3042
3043 $selected = (!empty($obj->country_code) ? $obj->country_code : (!empty($obj->country) ? $obj->country : ''));
3044 if (!GETPOSTISSET('code')) {
3045 $selected = GETPOST('countryidforinsert');
3046 }
3047 print $form->select_country($selected, $value, '', 28, 'minwidth100 maxwidth150 maxwidthonsmartphone');
3048 print '</td>';
3049 } elseif ($value == 'country_id') {
3050 if (!in_array('country', $fieldlist)) { // If there is already a field country, we don't show country_id (avoid duplicate)
3051 $country_id = (!empty($obj->{$value}) ? $obj->{$value} : 0);
3052 print '<td class="tdoverflowmax100">';
3053 print '<input type="hidden" name="'. $value .'" value="'.$country_id.'">';
3054 print '</td>';
3055 }
3056 } elseif ($value == 'region') {
3057 print '<td>';
3058 $formcompany->select_region($region_id, 'region');
3059 print '</td>';
3060 } elseif ($value == 'region_id') {
3061 $region_id = (!empty($obj->{$value}) ? $obj->{$value} : 0);
3062 print '<td>';
3063 print '<input type="hidden" name="'. $value .'" value="'.$region_id.'">';
3064 print '</td>';
3065 } elseif ($value == 'department_buyer') {
3066 if ($context == 'edit') {
3067 print '<td class="nowraponall">';
3068 // show department buyer list
3069 $country_code = (!empty($obj->country_code) ? $obj->country_code : '');
3070 $department_buyer_id = (!empty($obj->department_buyer_id) ? (int) $obj->department_buyer_id : 0);
3071 if ($country_code != '') {
3072 print $formcompany->select_state($department_buyer_id, $country_code, 'department_buyer_id', 'minwidth100 maxwidth150 maxwidthonsmartphone');
3073 }
3074 print '</td>';
3075 }
3076 } elseif ($value == 'department_buyer_id') {
3077 if (!in_array('department_buyer', $fieldlist)) { // If there is already a field department buyer, we don't show department buyer id (avoid duplicate)
3078 $department_buyer_id = (!empty($obj->{$value}) ? $obj->{$value} : 0);
3079 print '<td class="tdoverflowmax100">';
3080 print '<input type="hidden" name="'.$value.'" value="'.$department_buyer_id.'">';
3081 print '</td>';
3082 }
3083 } elseif ($value == 'lang') {
3084 print '<td>';
3085 print $formadmin->select_language(getDolGlobalString('MAIN_LANG_DEFAULT'), 'lang');
3086 print '</td>';
3087 } elseif (in_array($value, array('element', 'source'))) { // Example: the type and source of the element (for contact types)
3088 $tmparray = array();
3089 if ($value == 'element') {
3090 $tmparray = $elementList;
3091 } else {
3092 $tmparray = $sourceList;
3093 }
3094 print '<td>';
3095 print $form->selectarray($value, $tmparray, (!empty($obj->{$value}) ? $obj->{$value} : ''), 0, 0, 0, '', 0, 0, 0, '', 'maxwidth250');
3096 print '</td>';
3097 } elseif (in_array($value, array('public', 'use_default'))) {
3098 // Fields 0/1 with a combo select Yes/No
3099 print '<td class="center">';
3100 // @phan-suppress-next-line PhanPluginSuspiciousParamPosition
3101 print $form->selectyesno($value, (!empty($obj->{$value}) ? $obj->{$value} : ''), 1);
3102 print '</td>';
3103 } elseif ($value == 'private') {
3104 // Fields 'no'/'yes' with a combo select Yes/No
3105 print '<td>';
3106 print $form->selectyesno("private", (!empty($obj->{$value}) ? $obj->{$value} : ''));
3107 print '</td>';
3108 } elseif ($value == 'type' && $tabname == "c_actioncomm") {
3109 $type = (!empty($obj->type) ? $obj->type : 'user'); // Check if type is different of 'user' (external module)
3110 print '<td>';
3111 print $type.'<input type="hidden" name="type" value="'.$type.'">';
3112 print '</td>';
3113 } elseif ($value == 'type' && $tabname == 'c_paiement') {
3114 print '<td>';
3115 $select_list = array(0 => $langs->trans('PaymentTypeCustomer'), 1 => $langs->trans('PaymentTypeSupplier'), 2 => $langs->trans('PaymentTypeBoth'));
3116 // Use isset(), not !empty(), because 0 (Customer) is a valid value that empty() would treat as unset
3117 print $form->selectarray($value, $select_list, (isset($obj->{$value}) && $obj->{$value} !== '' ? $obj->{$value} : '2'));
3118 print '</td>';
3119 } elseif ($value == 'recuperableonly' || $value == 'type_cdr' || $value == 'deductible' || $value == 'category_type') {
3120 if ($value == 'type_cdr') {
3121 print '<td class="center">';
3122 } else {
3123 print '<td>';
3124 }
3125 if ($value == 'type_cdr') {
3126 print $form->selectarray($value, array(0 => $langs->trans('None'), 1 => $langs->trans('AtEndOfMonth'), 2 => $langs->trans('CurrentNext')), (!empty($obj->{$value}) ? $obj->{$value} : ''));
3127 } else {
3128 // @phan-suppress-next-line PhanPluginSuspiciousParamPosition
3129 print $form->selectyesno($value, (!empty($obj->{$value}) ? $obj->{$value} : ''), 1);
3130 }
3131 print '</td>';
3132 } elseif (in_array($value, array('nbjour', 'decalage', 'taux', 'localtax1', 'localtax2'))) {
3133 $class = "right";
3134 if (in_array($value, array('taux', 'localtax1', 'localtax2'))) {
3135 $class = "center"; // Fields aligned on right
3136 }
3137 print '<td class="'.$class.'">';
3138 print '<input type="text" class="flat" value="'.(isset($obj->{$value}) ? $obj->{$value} : '').'" size="3" name="'. $value .'">';
3139 print '</td>';
3140 } elseif (in_array($value, array('libelle_facture', 'content'))) {
3141 print '<td>';
3142 $transfound = 0;
3143 $transkey = '';
3144 // Special case for labels
3145 if ($tabname == 'c_payment_term') {
3146 $langs->load("bills");
3147 if (isset($obj->code) && !empty($obj->code)) {
3148 $transkey = "PaymentCondition" . strtoupper($obj->code);
3149 if ($langs->trans($transkey) != $transkey) {
3150 $transfound = 1;
3151 print $form->textwithpicto($langs->trans($transkey), $langs->trans("GoIntoTranslationMenuToChangeThis"));
3152 }
3153 }
3154 }
3155 if (!$transfound) {
3156 print '<textarea cols="30" rows="'.ROWS_2.'" class="flat" name="'. $value .'">'.(empty($obj->{$value}) ? '' : $obj->{$value}).'</textarea>';
3157 } else {
3158 print '<input type="hidden" name="'. $value .'" value="'.$transkey.'">';
3159 }
3160 print '</td>';
3161 } elseif ($value == 'price' || preg_match('/^amount/i', (string) $value)) {
3162 print '<td><input type="text" class="flat minwidth75" value="'.price((!empty($obj->{$value}) ? $obj->{$value} : '')).'" name="'. $value .'"></td>';
3163 } elseif ($value == 'code' && isset($obj->{$value})) {
3164 print '<td>';
3165 if ($tabname == 'c_paiement' && in_array($obj->{$value}, array('LIQ', 'CB', 'CHQ', 'VIR'))) {
3166 // Case of code that should not be modified
3167 print '<input type="hidden" class="flat minwidth75 maxwidth100" value="'.(empty($obj->{$value}) ? '' : $obj->{$value}).'" name="'. $value .'">';
3168 print $obj->{$value};
3169 } else {
3170 print '<input type="text" class="flat minwidth75 maxwidth100" value="'.(empty($obj->{$value}) ? '' : $obj->{$value}).'" name="'. $value .'">';
3171 }
3172 print '</td>';
3173 } elseif ($value == 'unit') {
3174 print '<td>';
3175 $units = array(
3176 'mm' => $langs->trans('SizeUnitmm'),
3177 'cm' => $langs->trans('SizeUnitcm'),
3178 'point' => $langs->trans('SizeUnitpoint'),
3179 'inch' => $langs->trans('SizeUnitinch')
3180 );
3181 print $form->selectarray('unit', $units, (empty($obj->{$value}) ? '' : $obj->{$value}), 0, 0, 0);
3182 print '</td>';
3183 } elseif ($value == 'type_vat') {
3184 // VAT type 0: all, 1: sell, 2: purchase
3185 print '<td class="center">';
3186 print $form->selectarray($value, $type_vatList, (empty($obj->{$value}) ? '0' : $obj->{$value}));
3187 print '</td>';
3188 } elseif ($value == 'localtax1_type' || $value == 'localtax2_type') {
3189 // Le type de taxe locale
3190 print '<td class="center">';
3191 print $form->selectarray($value, $localtax_typeList, (empty($obj->{$value}) ? '' : $obj->{$value}));
3192 print '</td>';
3193 } elseif ($value == 'accountancy_code' || $value == 'accountancy_code_sell' || $value == 'accountancy_code_buy') {
3194 print '<td>';
3195 if (isModEnabled('accounting')) {
3196 $fieldname = $value;
3197 $accountancy_account = (empty($obj->$fieldname) ? 0 : $obj->$fieldname);
3198 print $formaccounting->select_account($accountancy_account, '.'. $value, 1, array(), 1, 1, 'maxwidth125 maxwidthonsmartphone');
3199 } else {
3200 $fieldname = $value;
3201 print '<input type="text" class="flat minwidth100" value="'.(isset($obj->$fieldname) ? $obj->$fieldname : '').'" name="'. $value .'">';
3202 }
3203 print '</td>';
3204 } elseif ($value == 'fk_tva') {
3205 print '<td>';
3206 print $form->load_tva('fk_tva', $obj->taux, $mysoc, new Societe($db), 0, 0, '', false, -1);
3207 print '</td>';
3208 } elseif ($value == 'fk_c_exp_tax_cat') {
3209 print '<td>';
3210 print $form->selectExpenseCategories($obj->fk_c_exp_tax_cat);
3211 print '</td>';
3212 } elseif ($value == 'fk_range') {
3213 print '<td>';
3214 print $form->selectExpenseRanges($obj->fk_range);
3215 print '</td>';
3216 } elseif ($value == 'block_if_negative') {
3217 print '<td>';
3218 print $form->selectyesno("block_if_negative", (empty($obj->block_if_negative) ? '' : $obj->block_if_negative), 1);
3219 print '</td>';
3220 } elseif ($value == 'type_duration') {
3221 print '<td>';
3222 print $form->selectTypeDuration('', (empty($obj->type_duration) ? '' : $obj->type_duration), ['s', 'i', 'h']);
3223 print '</td>';
3224 } elseif ($value == 'color') {
3225 print '<td>';
3226 print $formother->selectColor((empty($obj->{$value}) ? '' : $obj->{$value}), 'color');
3227 print '</td>';
3228 } else {
3229 $fieldValue = isset($obj->{$value}) ? $obj->{$value} : '';
3230 $classtd = '';
3231 $class = '';
3232
3233 if ($value == 'sortorder') {
3234 $fieldlist[$field] = 'position';
3235 }
3236
3237 if ($fieldlist[$field] == 'code') {
3238 $class = 'maxwidth100';
3239 }
3240 if (in_array($fieldlist[$field], array('deposit_percent'))) {
3241 $classtd = 'right';
3242 $class = 'maxwidth50 right';
3243 }
3244 if (in_array($fieldlist[$field], array('pos', 'position'))) {
3245 $classtd = 'right';
3246 $class = 'maxwidth50 right';
3247 }
3248 if (in_array($fieldlist[$field], array('dayrule', 'day', 'month', 'year', 'use_default', 'affect', 'delay', 'public', 'sortorder', 'sens', 'category_type', 'fk_parent'))) {
3249 $class = 'maxwidth50 center';
3250 }
3251 if (in_array($fieldlist[$field], array('use_default', 'public', 'fk_parent'))) {
3252 $classtd = 'center';
3253 }
3254 if (in_array($fieldlist[$field], array('libelle', 'label', 'tracking'))) {
3255 $class = 'quatrevingtpercent';
3256 }
3257 // Fields that must be suggested as '0' instead of ''
3258 if ($fieldlist[$field] == 'fk_parent') {
3259 if (empty($fieldValue)) {
3260 $fieldValue = '0';
3261 }
3262 }
3263
3264 // Labels Length
3265 $maxlength = '';
3266 if (in_array($fieldlist[$field], array('libelle', 'label'))) {
3267 switch ($tabname) {
3268 case 'c_ecotaxe':
3269 case 'c_email_senderprofile':
3270 case 'c_forme_juridique':
3271 case 'c_holiday_types':
3272 case 'c_payment_term':
3273 case 'c_transport_mode':
3274 $maxlength = ' maxlength="255"';
3275 break;
3276 case 'c_email_templates':
3277 $maxlength = ' maxlength="180"';
3278 break;
3279 case 'c_socialnetworks':
3280 $maxlength = ' maxlength="150"';
3281 break;
3282 default:
3283 $maxlength = ' maxlength="128"';
3284 }
3285 }
3286
3287 print '<td class="'.$classtd.'">';
3288 $transfound = 0;
3289 $transkey = '';
3290 if (in_array($fieldlist[$field], array('label', 'libelle'))) { // For label
3291 // Special case for labels
3292 if ($tabname == 'c_civility' && !empty($obj->code)) {
3293 $transkey = "Civility".strtoupper($obj->code);
3294 }
3295 if ($tabname == 'c_payment_term' && !empty($obj->code)) {
3296 $langs->load("bills");
3297 $transkey = "PaymentConditionShort".strtoupper($obj->code);
3298 }
3299 if ($transkey && $langs->trans($transkey) != $transkey) {
3300 $transfound = 1;
3301 print $form->textwithpicto($langs->trans($transkey), $langs->trans("GoIntoTranslationMenuToChangeThis"));
3302 }
3303 }
3304 if (!$transfound) {
3305 print '<input type="text" class="flat'.($class ? ' '.$class : '').'"'.($maxlength ? ' '.$maxlength : '').' value="'.dol_escape_htmltag($fieldValue).'" name="'.$fieldlist[$field].'">';
3306 } else {
3307 print '<input type="hidden" name="'.$fieldlist[$field].'" value="'.$transkey.'">';
3308 }
3309 print '</td>';
3310 }
3311 }
3312
3313 return $withentity;
3314}
$id
Support class for third parties, contacts, members, users or resources.
Definition account.php:47
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
length_accountg($account)
Return General accounting account with defined length (used for product and miscellaneous)
$propal type
'integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter[:Sortfield]]]',...
Definition propal.php:281
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
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
Class to manage accounting accounts.
Class to manage generation of HTML components for accounting management.
Class to generate html code for admin pages.
Class to build HTML component for third parties management Only common components are here.
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 third parties objects (customers, suppliers, prospects...)
$context
@method int call_trigger(string $triggerName, ?User $user)
Definition command.php:209
global $mysoc
dictFieldLabel($value, $tabname='', $tablib='')
Return the label of a field of a dictionary, translated, to use as title of a column.
Definition dict.php:2791
dictFieldList($fieldlist, $obj=null, $tabname='', $context='')
Show fields in insert/edit mode.
Definition dict.php:3009
price2num($amount, $rounding='', $option=0, $currencycode='')
Function that return a number with universal decimal format (decimal separator is '.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
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.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
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.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
getDictionaryValue($tablename, $field, $id, $checkentity=false, $rowidfield='rowid')
Return the value of a filed into a dictionary for the record $id.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
getEntity($element, $shared=1, $currentobject=null)
Get list of entity id to use.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
Definition html.lib.php:542
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_get_fiche_end($notab=0)
Return tab footer of a card.
Definition html.lib.php:740
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip='', $forcenowrapcolumntitle=0)
Get title line of an array.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='', $picto='', $textonpictotooltip='', $cssfordropdown='info_admin')
Show information in HTML for admin users or standard users.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Definition html.lib.php:183
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.