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("errors", "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, 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";
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";
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";
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";
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');
907 foreach ($notmandatoryarray as $notmandatory) {
908 if (!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 setEventMessages($langs->transnoentities("ErrorFieldMustBeANumeric", $langs->transnoentities("Code")), null, 'errors');
1001 }
1002 if ($id == DICT_COUNTRY && strlen(GETPOST("code")) != 2) { // 2 char on code for country code
1003 $ok = 0;
1004 setEventMessages($langs->transnoentities("ErrorCountryCodeMustBe2Char", $langs->transnoentities("Code")), null, 'errors');
1005 }
1006 if ($id == DICT_PAIEMENT && strlen(GETPOST("code")) >= 6) { // 6 char max on code for payment mode codes
1007 $ok = 0;
1008 setEventMessages($langs->transnoentities("ErrorFieldMustHaveLessThanXChar", $langs->transnoentities("Code"), '6'), null, 'errors');
1009 }
1010
1011 // Clean some parameters
1012 if ((GETPOST("localtax1_type") || (GETPOST('localtax1_type') == '0')) && !GETPOST("localtax1")) {
1013 $_POST["localtax1"] = '0'; // If empty, we force to 0
1014 }
1015 if ((GETPOST("localtax2_type") || (GETPOST('localtax2_type') == '0')) && !GETPOST("localtax2")) {
1016 $_POST["localtax2"] = '0'; // If empty, we force to 0
1017 }
1018 if (GETPOST('department_buyer_id') <= 0) {
1019 $_POST['department_buyer_id'] = ''; // If empty, we force to null
1020 }
1021 if (GETPOST("accountancy_code") <= 0) {
1022 $_POST["accountancy_code"] = ''; // If empty, we force to null
1023 }
1024 if (GETPOST("accountancy_code_sell") <= 0) {
1025 $_POST["accountancy_code_sell"] = ''; // If empty, we force to null
1026 }
1027 if (GETPOST("accountancy_code_buy") <= 0) {
1028 $_POST["accountancy_code_buy"] = ''; // If empty, we force to null
1029 }
1030 if ($id == DICT_TVA && GETPOSTISSET("code")) { // Spaces are not allowed into code for tax dictionary
1031 $_POST["code"] = preg_replace('/[^a-zA-Z0-9_\-\+]/', '', GETPOST("code"));
1032 }
1033
1034 $tablename = $tabname[$id];
1035 $tablename = preg_replace('/^'.preg_quote(MAIN_DB_PREFIX, '/').'/', '', $tablename);
1036
1037 // If check ok and action add, add the line
1038 if ($ok && GETPOST('actionadd')) {
1039 $newid = 0;
1040 if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldinsert)) {
1041 // Get free id for insert
1042 $sql = "SELECT MAX(".$tabrowid[$id].") as newid FROM ".MAIN_DB_PREFIX.$db->sanitize($tablename);
1043 $result = $db->query($sql);
1044 if ($result) {
1045 $obj = $db->fetch_object($result);
1046 $newid = ((int) $obj->newid) + 1;
1047 } else {
1048 dol_print_error($db);
1049 }
1050 }
1051
1052 // Add new entry
1053 $sql = "INSERT INTO ".MAIN_DB_PREFIX.$db->sanitize($tablename)." (";
1054 // List of fields
1055 if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldinsert)) {
1056 $sql .= $tabrowid[$id].",";
1057 }
1058 $sql .= $tabfieldinsert[$id];
1059 $sql .= ",active)";
1060 $sql .= " VALUES(";
1061
1062 // List of values
1063 if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldinsert)) {
1064 $sql .= ((int) $newid).",";
1065 }
1066 $i = 0;
1067 foreach ($listfieldinsert as $f => $value) {
1068 $keycode = (isset($listfieldvalue[$i]) ? $listfieldvalue[$i] : '');
1069 if (empty($keycode)) {
1070 $keycode = $value;
1071 }
1072
1073 if ($value == 'price' || preg_match('/^amount/i', $value)) {
1074 $_POST[$keycode] = price2num(GETPOST($keycode), 'MU');
1075 } elseif ($value == 'taux' || $value == 'localtax1') {
1076 $_POST[$keycode] = price2num(GETPOST($keycode), 8); // Note that localtax2 can be a list of rates separated by coma like X:Y:Z
1077 } elseif ($value == 'entity') {
1078 $_POST[$keycode] = (int) getEntity($tablename, 0);
1079 }
1080
1081 if ($i) {
1082 $sql .= ",";
1083 }
1084
1085 if ($keycode == 'sortorder') { // For column name 'sortorder', we use the field name 'position'
1086 $sql .= GETPOSTINT('position');
1087 } elseif (GETPOST($keycode) == '' && !($keycode == 'code' && $id == DICT_TVA)) {
1088 $sql .= "null"; // For vat, we want/accept code = ''
1089 } elseif ($keycode == 'content') {
1090 $sql .= "'".$db->escape(GETPOST($keycode, 'restricthtml'))."'";
1091 } elseif (in_array($keycode, array('joinfile', 'private', 'pos', 'position', 'scale', 'use_default'))) {
1092 $sql .= GETPOSTINT($keycode);
1093 } else {
1094 $sql .= "'".$db->escape(GETPOST($keycode, 'alphanohtml'))."'";
1095 }
1096
1097 $i++;
1098 }
1099 $sql .= ",1)";
1100
1101 dol_syslog("actionadd", LOG_DEBUG);
1102 $resql = $db->query($sql);
1103 if ($resql) { // Add is ok
1104 setEventMessages($langs->transnoentities("RecordCreatedSuccessfully"), null, 'mesgs');
1105
1106 // PostgreSQL: when we forced the rowid we must bump the matching <table>_<rowid_col>_seq
1107 // so the next auto-increment insert does not collide with our chosen value (#36510).
1108 if ($db->type == 'pgsql' && $tabrowid[$id] && !in_array($tabrowid[$id], $listfieldinsert)) {
1109 $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))");
1110 }
1111
1112 // Clean $_POST array, we keep only id of dictionary
1113 if ($id == DICT_TVA && GETPOSTINT('country') > 0) {
1114 $search_country_id = GETPOSTINT('country');
1115 }
1116 $_POST = array('id' => $id);
1117 } else {
1118 if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
1119 setEventMessages($langs->transnoentities("ErrorRecordAlreadyExists"), null, 'errors');
1120 } else {
1121 dol_print_error($db);
1122 }
1123 }
1124 }
1125
1126 // If verif ok and action modify, modify the line
1127 if ($ok && GETPOST('actionmodify')) {
1128 if ($tabrowid[$id]) {
1129 $rowidcol = $tabrowid[$id];
1130 } else {
1131 $rowidcol = "rowid";
1132 }
1133
1134 // Modify entry
1135 $sql = "UPDATE ".MAIN_DB_PREFIX.$db->sanitize($tablename)." SET ";
1136 // Update fields value
1137 if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldmodify)) {
1138 $sql .= $tabrowid[$id]."=";
1139 $sql .= "'".$db->escape($rowid)."', ";
1140 }
1141 $i = 0;
1142 foreach ($listfieldmodify as $field) {
1143 $keycode = empty($listfieldvalue[$i]) ? '' : $listfieldvalue[$i];
1144 if (empty($keycode)) {
1145 $keycode = $field;
1146 }
1147
1148 if ($field == 'price' || preg_match('/^amount/i', $field)) {
1149 $_POST[$keycode] = price2num(GETPOST($keycode), 'MU');
1150 } elseif ($field == 'taux' || $field == 'localtax1') {
1151 $_POST[$keycode] = price2num(GETPOST($keycode), 8); // Note that localtax2 can be a list of rates separated by coma like X:Y:Z
1152 } elseif ($field == 'entity') {
1153 $_POST[$keycode] = (int) getEntity($tablename, 0);
1154 }
1155
1156 if ($i) {
1157 $sql .= ",";
1158 }
1159 $sql .= $field."=";
1160 if ($keycode == 'sortorder') { // For column name 'sortorder', we use the field name 'position'
1161 $sql .= GETPOSTINT('position');
1162 } elseif (GETPOST($keycode) == '' && !($keycode == 'code' && $id == DICT_TVA)) {
1163 $sql .= "null"; // For vat, we want/accept code = ''
1164 } elseif ($keycode == 'content') {
1165 $sql .= "'".$db->escape(GETPOST($keycode, 'restricthtml'))."'";
1166 } elseif (in_array($keycode, array('joinfile', 'private', 'pos', 'position', 'scale', 'use_default'))) {
1167 $sql .= GETPOSTINT($keycode);
1168 } else {
1169 $sql .= "'".$db->escape(GETPOST($keycode, 'alphanohtml'))."'";
1170 }
1171
1172 $i++;
1173 }
1174 if (in_array($rowidcol, array('code', 'code_iso'))) {
1175 $sql .= " WHERE ".$db->sanitize($rowidcol)." = '".$db->escape($rowid)."'";
1176 } else {
1177 $sql .= " WHERE ".$db->sanitize($rowidcol)." = ".((int) $rowid);
1178 }
1179 if (in_array('entity', $listfieldmodify)) {
1180 $sql .= " AND entity = ".((int) getEntity($tablename, 0));
1181 }
1182
1183 dol_syslog("actionmodify", LOG_DEBUG);
1184 //print $sql;
1185 $resql = $db->query($sql);
1186 if (!$resql) {
1187 setEventMessages($db->error(), null, 'errors');
1188 }
1189 }
1190
1191 if (!$ok && GETPOST('actionadd')) {
1192 $action = 'create';
1193 }
1194 if (!$ok && GETPOST('actionmodify')) {
1195 $action = 'edit';
1196 }
1197 }
1198
1199 if ($action == 'confirm_delete' && $confirm == 'yes') { // delete
1200 if ($tabrowid[$id]) {
1201 $rowidcol = $tabrowid[$id];
1202 } else {
1203 $rowidcol = "rowid";
1204 }
1205
1206 $tablename = $tabname[$id];
1207 $tablename = preg_replace('/^'.preg_quote(MAIN_DB_PREFIX, '/').'/', '', $tablename);
1208
1209 $sql = "DELETE FROM ".MAIN_DB_PREFIX.$db->sanitize($tablename)." WHERE ".$db->sanitize($rowidcol)." = '".$db->escape($rowid)."'".($entity != '' ? " AND entity = ".(int) $entity : '');
1210
1211 dol_syslog("delete", LOG_DEBUG);
1212 $result = $db->query($sql);
1213 if (!$result) {
1214 if ($db->errno() == 'DB_ERROR_CHILD_EXISTS') {
1215 setEventMessages($langs->transnoentities("ErrorRecordIsUsedByChild"), null, 'errors');
1216 } else {
1217 dol_print_error($db);
1218 }
1219 }
1220 }
1221
1222 // activate
1223 if ($action == $acts[0]) {
1224 if ($tabrowid[$id]) {
1225 $rowidcol = $tabrowid[$id];
1226 } else {
1227 $rowidcol = "rowid";
1228 }
1229
1230 $tablename = $tabname[$id];
1231 $tablename = preg_replace('/^'.preg_quote(MAIN_DB_PREFIX, '/').'/', '', $tablename);
1232
1233 if ($rowid) {
1234 $sql = "UPDATE ".MAIN_DB_PREFIX.$db->sanitize($tablename)." SET active = 1 WHERE ".$db->sanitize($rowidcol)." = ".((int) $rowid).($entity != '' ? " AND entity = ".(int) $entity : '');
1235 } elseif ($code) {
1236 $sql = "UPDATE ".MAIN_DB_PREFIX.$db->sanitize($tablename)." SET active = 1 WHERE code = '".$db->escape(dol_escape_htmltag($code))."'".($entity != '' ? " AND entity = ".(int) $entity : '');
1237 } else {
1238 $sql = null;
1239 }
1240
1241 if ($sql !== null) {
1242 $result = $db->query($sql);
1243 if (!$result) {
1244 dol_print_error($db);
1245 }
1246 } else {
1247 dol_print_error(null, "No DB entry or no code");
1248 }
1249 }
1250
1251 // disable
1252 if ($action == $acts[1]) {
1253 if ($tabrowid[$id]) {
1254 $rowidcol = $tabrowid[$id];
1255 } else {
1256 $rowidcol = "rowid";
1257 }
1258
1259 $tablename = $tabname[$id];
1260 $tablename = preg_replace('/^'.preg_quote(MAIN_DB_PREFIX, '/').'/', '', $tablename);
1261
1262 if ($rowid) {
1263 $sql = "UPDATE ".MAIN_DB_PREFIX.$db->sanitize($tablename)." SET active = 0 WHERE ".$db->sanitize($rowidcol)." = '".$db->escape($rowid)."'".($entity != '' ? " AND entity = ".(int) $entity : '');
1264 } elseif ($code) {
1265 $sql = "UPDATE ".MAIN_DB_PREFIX.$db->sanitize($tablename)." SET active = 0 WHERE code = '".$db->escape(dol_escape_htmltag($code))."'".($entity != '' ? " AND entity = ".(int) $entity : '');
1266 } else {
1267 $sql = null;
1268 }
1269
1270 if ($sql !== null) {
1271 $result = $db->query($sql);
1272 if (!$result) {
1273 dol_print_error($db);
1274 }
1275 } else {
1276 dol_print_error(null, "No DB entry or no code");
1277 }
1278 }
1279
1280 // favorite
1281 if ($action == 'activate_favorite') {
1282 if ($tabrowid[$id]) {
1283 $rowidcol = $tabrowid[$id];
1284 } else {
1285 $rowidcol = "rowid";
1286 }
1287
1288 $tablename = $tabname[$id];
1289 $tablename = preg_replace('/^'.preg_quote(MAIN_DB_PREFIX, '/').'/', '', $tablename);
1290
1291 if ($rowid) {
1292 $sql = "UPDATE ".MAIN_DB_PREFIX.$db->sanitize($tablename)." SET favorite = 1 WHERE ".$db->sanitize($rowidcol)." = '".$db->escape($rowid)."'".($entity != '' ? " AND entity = ".(int) $entity : '');
1293 } elseif ($code) {
1294 $sql = "UPDATE ".MAIN_DB_PREFIX.$db->sanitize($tablename)." SET favorite = 1 WHERE code = '".$db->escape(dol_escape_htmltag($code))."'".($entity != '' ? " AND entity = ".(int) $entity : '');
1295 } else {
1296 $sql = null;
1297 }
1298
1299 if ($sql !== null) {
1300 $result = $db->query($sql);
1301 if (!$result) {
1302 dol_print_error($db);
1303 }
1304 } else {
1305 dol_print_error(null, "No DB entry or no code");
1306 }
1307 }
1308
1309 // disable favorite
1310 if ($action == 'disable_favorite') {
1311 if ($tabrowid[$id]) {
1312 $rowidcol = $tabrowid[$id];
1313 } else {
1314 $rowidcol = "rowid";
1315 }
1316
1317 $tablename = $tabname[$id];
1318 $tablename = preg_replace('/^'.preg_quote(MAIN_DB_PREFIX, '/').'/', '', $tablename);
1319
1320 if ($rowid) {
1321 $sql = "UPDATE ".MAIN_DB_PREFIX.$db->sanitize($tablename)." SET favorite = 0 WHERE ".$db->sanitize($rowidcol)." = '".$db->escape($rowid)."'".($entity != '' ? " AND entity = ".(int) $entity : '');
1322 } elseif ($code) {
1323 $sql = "UPDATE ".MAIN_DB_PREFIX.$db->sanitize($tablename)." SET favorite = 0 WHERE code = '".$db->escape(dol_escape_htmltag($code))."'".($entity != '' ? " AND entity = ".(int) $entity : '');
1324 } else {
1325 $sql = null;
1326 }
1327
1328 if ($sql !== null) {
1329 $result = $db->query($sql);
1330 if (!$result) {
1331 dol_print_error($db);
1332 }
1333 } else {
1334 dol_print_error(null, "No DB entry or no code");
1335 }
1336 }
1337
1338 // Is in EEC - Activate
1339 if ($action == 'activate_eec') {
1340 if ($tabrowid[$id]) {
1341 $rowidcol = $tabrowid[$id];
1342 } else {
1343 $rowidcol = "rowid";
1344 }
1345
1346 $tablename = $tabname[$id];
1347 $tablename = preg_replace('/^'.preg_quote(MAIN_DB_PREFIX, '/').'/', '', $tablename);
1348
1349 if ($rowid) {
1350 $sql = "UPDATE ".MAIN_DB_PREFIX.$db->sanitize($tablename)." SET eec = 1 WHERE ".$db->sanitize($rowidcol)." = '".$db->escape($rowid)."'".($entity != '' ? " AND entity = ".(int) $entity : '');
1351 } elseif ($code) {
1352 $sql = "UPDATE ".MAIN_DB_PREFIX.$db->sanitize($tablename)." SET eec = 1 WHERE code = '".$db->escape(dol_escape_htmltag($code))."'".($entity != '' ? " AND entity = ".(int) $entity : '');
1353 } else {
1354 $sql = null;
1355 }
1356
1357 if ($sql !== null) {
1358 $result = $db->query($sql);
1359 if (!$result) {
1360 dol_print_error($db);
1361 }
1362 } else {
1363 dol_print_error(null, "No DB entry or no code");
1364 }
1365 }
1366
1367 // Is in EEC - Disable
1368 if ($action == 'disable_eec') {
1369 if ($tabrowid[$id]) {
1370 $rowidcol = $tabrowid[$id];
1371 } else {
1372 $rowidcol = "rowid";
1373 }
1374
1375 $tablename = $tabname[$id];
1376 $tablename = preg_replace('/^'.preg_quote(MAIN_DB_PREFIX, '/').'/', '', $tablename);
1377
1378 if ($rowid) {
1379 $sql = "UPDATE ".MAIN_DB_PREFIX.$db->sanitize($tablename)." SET eec = 0 WHERE ".$db->sanitize($rowidcol)." = '".$db->escape($rowid)."'".($entity != '' ? " AND entity = ".(int) $entity : '');
1380 } elseif ($code) {
1381 $sql = "UPDATE ".MAIN_DB_PREFIX.$db->sanitize($tablename)." SET eec = 0 WHERE code = '".$db->escape(dol_escape_htmltag($code))."'".($entity != '' ? " AND entity = ".(int) $entity : '');
1382 } else {
1383 $sql = null;
1384 }
1385
1386 if ($sql !== null) {
1387 $result = $db->query($sql);
1388 if (!$result) {
1389 dol_print_error($db);
1390 }
1391 } else {
1392 dol_print_error(null, "No DB entry or no code");
1393 }
1394 }
1395
1396 // Is in Sepa - Activate
1397 if ($action == 'activate_sepa') {
1398 if ($tabrowid[$id]) {
1399 $rowidcol = $tabrowid[$id];
1400 } else {
1401 $rowidcol = "rowid";
1402 }
1403
1404 $tablename = $tabname[$id];
1405 $tablename = preg_replace('/^'.preg_quote(MAIN_DB_PREFIX, '/').'/', '', $tablename);
1406
1407 if ($rowid) {
1408 $sql = "UPDATE ".MAIN_DB_PREFIX.$db->sanitize($tablename)." SET sepa = 1 WHERE ".$db->sanitize($rowidcol)." = '".$db->escape($rowid)."'".($entity != '' ? " AND entity = ".(int) $entity : '');
1409 } elseif ($code) {
1410 $sql = "UPDATE ".MAIN_DB_PREFIX.$db->sanitize($tablename)." SET sepa = 1 WHERE code = '".$db->escape(dol_escape_htmltag($code))."'".($entity != '' ? " AND entity = ".(int) $entity : '');
1411 } else {
1412 $sql = null;
1413 }
1414
1415 if ($sql !== null) {
1416 $result = $db->query($sql);
1417 if (!$result) {
1418 dol_print_error($db);
1419 }
1420 } else {
1421 dol_print_error(null, "No DB entry or no code");
1422 }
1423 }
1424
1425 // Is in Sepa - Disable
1426 if ($action == 'disable_sepa') {
1427 if ($tabrowid[$id]) {
1428 $rowidcol = $tabrowid[$id];
1429 } else {
1430 $rowidcol = "rowid";
1431 }
1432
1433 $tablename = $tabname[$id];
1434 $tablename = preg_replace('/^'.preg_quote(MAIN_DB_PREFIX, '/').'/', '', $tablename);
1435
1436 if ($rowid) {
1437 $sql = "UPDATE ".MAIN_DB_PREFIX.$db->sanitize($tablename)." SET sepa = 0 WHERE ".$db->sanitize($rowidcol)." = '".$db->escape($rowid)."'".($entity != '' ? " AND entity = ".(int) $entity : '');
1438 } elseif ($code) {
1439 $sql = "UPDATE ".MAIN_DB_PREFIX.$db->sanitize($tablename)." SET sepa = 0 WHERE code = '".$db->escape(dol_escape_htmltag($code))."'".($entity != '' ? " AND entity = ".(int) $entity : '');
1440 } else {
1441 $sql = null;
1442 }
1443
1444 if ($sql !== null) {
1445 $result = $db->query($sql);
1446 if (!$result) {
1447 dol_print_error($db);
1448 }
1449 } else {
1450 dol_print_error(null, "No DB entry or no code");
1451 }
1452 }
1453}
1454
1455
1456/*
1457 * View
1458 */
1459global $form, $formother; // Used in dictFieldList() below
1460
1461$form = new Form($db);
1462$formother = new FormOther($db);
1463
1464$title = $langs->trans("DictionarySetup");
1465
1466llxHeader('', $title, '', '', 0, 0, '', '', '', 'mod-admin page-dict');
1467
1468if (GETPOSTINT('id') == DICT_SOCIALNETWORKS && $from == 'socialnetworksetup') {
1469 $head = socialnetwork_prepare_head();
1470 print dol_get_fiche_head($head, 'dict', $langs->trans('MenuDict'), -1, 'user');
1471}
1472
1473
1474$linkback = '';
1475if ($id && empty($from)) {
1476 $title .= ' - '.$langs->trans($tablib[$id]);
1477 $linkback = '<a href="'.$_SERVER['PHP_SELF'].'">'.img_picto($langs->trans("BackToDictionaryList"), 'back', 'class="pictofixedwidth"').'<span class="hideonsmartphone">'.$langs->trans("BackToDictionaryList").'</span></a>';
1478}
1479$titlepicto = 'title_setup';
1480if ($id == DICT_TVA && GETPOST('from') == 'accountancy') {
1481 $title = $langs->trans("MenuVatAccounts");
1482 $titlepicto = 'accountancy';
1483}
1484if ($id == DICT_CHARGESOCIALES && GETPOST('from') == 'accountancy') {
1485 $title = $langs->trans("MenuTaxAccounts");
1486 $titlepicto = 'accountancy';
1487}
1488
1489$param = '&id='.urlencode((string) ($id));
1490if ($search_country_id || GETPOSTISSET('page') || GETPOST('button_removefilter', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter_x', 'alpha')) {
1491 $param .= '&search_country_id='.urlencode((string) ($search_country_id ? $search_country_id : -1));
1492}
1493if ($search_code != '') {
1494 $param .= '&search_code='.urlencode($search_code);
1495}
1496if ($search_active != '') {
1497 $param .= '&search_active='.urlencode($search_active);
1498}
1499if ($entity != '') {
1500 $param .= '&entity='.(int) $entity;
1501}
1502if ($from) {
1503 $param .= '&from='.urlencode($from);
1504}
1505$paramwithsearch = $param;
1506if ($sortorder) {
1507 $paramwithsearch .= '&sortorder='.urlencode($sortorder);
1508}
1509if ($sortfield) {
1510 $paramwithsearch .= '&sortfield='.urlencode($sortfield);
1511}
1512if ($from) {
1513 $paramwithsearch .= '&from='.urlencode($from);
1514}
1515
1516
1517// Confirmation of the deletion of the line
1518if ($action == 'delete') {
1519 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);
1520}
1521
1522// Show a dictionary
1523if ($id > 0) {
1524 // Complete search values request with sort criteria
1525 $sqlfields = $tabsql[$id];
1526
1527 $tablecode = 't.code';
1528 $tableprefix = '';
1529 $tableprefixarray = array(
1530 DICT_FORME_JURIDIQUE => 'f.code',
1531 DICT_DEPARTEMENTS => 'd.code_departement',
1532 DICT_REGIONS => 'r.code_region',
1533 DICT_COUNTRY => 'c.code',
1534 DICT_CIVILITY => 'c.code',
1535 DICT_ACTIONCOMM => 'a.code',
1536 DICT_CHARGESOCIALES => 'a.code',
1537 DICT_TYPENT => 't.code',
1538 DICT_CURRENCIES => 'c.code_iso',
1539 DICT_ECOTAXE => 'e.code',
1540 DICT_HOLIDAY_TYPES => 'h.code',
1541 DICT_HRM_PUBLIC_HOLIDAY => 'a.code',
1542 DICT_UNITS => 'r.code',
1543 DICT_SOCIALNETWORKS => 's.code',
1544 45 => 'f.code',
1545 46 => 'f.code',
1546 47 => 'f.code',
1547 48 => 'f.code',
1548 );
1549 if (!empty($tableprefixarray[$id])) {
1550 $tablecode = $tableprefixarray[$id];
1551 $tableprefix = preg_replace('/\..*$/', '.', $tablecode);
1552 }
1553 $reg = array();
1554 if (empty($tableprefix) && preg_match('/SELECT ([a-z]\.)rowid/i', $sqlfields, $reg)) {
1555 $tableprefix = $reg[1];
1556 }
1557
1558 $sql = $sqlfields;
1559 if (!preg_match('/ WHERE /', $sql)) {
1560 $sql .= " WHERE 1 = 1";
1561 }
1562 if ($search_country_id > 0) {
1563 if ($id == DICT_HRM_PUBLIC_HOLIDAY || $id == DICT_HOLIDAY_TYPES) {
1564 $sql .= " AND (c.rowid IS NULL OR c.rowid = 0 OR c.rowid = ".((int) $search_country_id).")";
1565 } else {
1566 $sql .= " AND c.rowid = ".((int) $search_country_id);
1567 }
1568 }
1569 if ($search_code != '') {
1570 $sql .= natural_search($tablecode, $search_code);
1571 }
1572 if ($search_active == 'yes') {
1573 $sql .= " AND ".$db->sanitize($tableprefix)."active = 1";
1574 } elseif ($search_active == 'no') {
1575 $sql .= " AND ".$db->sanitize($tableprefix)."active = 0";
1576 }
1577
1578 // Count total nb of records
1579 $nbtotalofrecords = '';
1580 if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
1581 /* The fast and low memory method to get and count full list converts the sql into a sql count */
1582 $sqlforcount = preg_replace('/^.*\sFROM\s/', 'SELECT COUNT(*) as nbtotalofrecords FROM ', $sql);
1583 $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount);
1584 $resql = $db->query($sqlforcount);
1585 if ($resql) {
1586 $objforcount = $db->fetch_object($resql);
1587 $nbtotalofrecords = $objforcount->nbtotalofrecords;
1588 } else {
1589 dol_print_error($db);
1590 }
1591
1592 if (($page * $listlimit) > $nbtotalofrecords) { // if total resultset is smaller than the paging size (filtering), goto and load page 0
1593 $page = 0;
1594 $offset = 0;
1595 }
1596 $db->free($resql);
1597 }
1598
1599 if ($sortfield) {
1600 // If sort order is "country", we use country_code instead
1601 if ($sortfield == 'country') {
1602 $sortfield = 'country_code';
1603 }
1604 $sql .= $db->order($sortfield, $sortorder);
1605 $sql .= ", ";
1606 // Clear the required sort criteria for the tabsqlsort to be able to force it with selected value
1607 $tabsqlsort[$id] = preg_replace('/([a-z]+\.)?'.$sortfield.' '.$sortorder.',/i', '', $tabsqlsort[$id]);
1608 $tabsqlsort[$id] = preg_replace('/([a-z]+\.)?'.$sortfield.',/i', '', $tabsqlsort[$id]);
1609 } else {
1610 $sql .= " ORDER BY ";
1611 }
1612 $sql .= $tabsqlsort[$id];
1613
1614 $sql .= $db->plimit($listlimit + 1, $offset);
1615
1616 //print $sql;
1617
1618 if (empty($tabfield[$id])) {
1619 dol_print_error($db, 'The table with id '.$id.' has no array tabfield defined');
1620 exit;
1621 }
1622 $fieldlist = explode(',', $tabfield[$id]);
1623
1624 // Definition of array of fields for columns.
1625 // $val['label'] is the label of column shown into the selector of columns, $val['checked'] is 1 when
1626 // the column is shown (main fields are shown by default, other ones only when selected by user).
1627 $arrayfields = array();
1628 $mainfieldlist = explode(',', str_replace(' ', '', empty($tabfieldmain[$id]) ? $tabfield[$id] : $tabfieldmain[$id])); // Fields shown by default
1629 foreach ($fieldlist as $key => $value) {
1630 if (empty($value) || in_array($value, array('entity', 'region_id', 'country_id', 'department_buyer_id'))) {
1631 continue; // Technical fields are never displayed and not selectable
1632 }
1633 $arrayfields[$value] = array(
1634 'label' => dictFieldLabel($value, $tabname[$id], $tablib[$id]),
1635 'checked' => (in_array($value, $mainfieldlist) ? 1 : 0),
1636 'position' => (int) $key
1637 );
1638 }
1639
1640 print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$id.'" method="POST" spellcheck="false">';
1641 print '<input type="hidden" name="token" value="'.newToken().'">';
1642 print '<input type="hidden" name="from" value="'.dol_escape_htmltag($from).'">';
1643 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
1644
1645 // Special warning for VAT dictionary
1646 if ($id == DICT_TVA && !getDolGlobalString('FACTURE_TVAOPTION')) {
1647 print info_admin($langs->trans("VATIsUsedIsOff", $langs->transnoentities("Setup"), $langs->transnoentities("CompanyFoundation")));
1648 print "<br>\n";
1649 }
1650
1651 // List of available record in database
1652 dol_syslog("htdocs/admin/dict", LOG_DEBUG);
1653
1654 $resql = $db->query($sql);
1655 if ($resql) {
1656 $num = $db->num_rows($resql);
1657 $i = 0;
1658
1659 $massactionbutton = $linkback;
1660
1661 $newcardbutton = '';
1662 /*$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'));
1663 $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'));
1664 $newcardbutton .= dolGetButtonTitleSeparator();
1665 */
1666 $newcardbutton .= dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/admin/dict.php?action=create'.$param.'&backtopage='.urlencode($_SERVER['PHP_SELF']), '', $permissiontoadd);
1667
1668 print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'tools', 0, $newcardbutton, '', $listlimit, 'listlimit', 0, 1);
1669
1670
1671 if ($action == 'create') {
1672 // Form to add a new line
1673 if ($tabname[$id]) {
1674 $withentity = null;
1675
1676 $fieldlist = explode(',', $tabfield[$id]);
1677
1678 print '<div class="div-table-responsive-no-min">';
1679 print '<table class="noborder centpercent">';
1680
1681 // Line for title
1682 print '<!-- line title to add new entry -->';
1683 $tdsoffields = '<tr class="liste_titre">';
1684 foreach ($fieldlist as $field => $value) {
1685 if ($value == 'entity') {
1686 $withentity = (int) getEntity($tabname[$id], 0);
1687 continue;
1688 }
1689
1690 // Define field friendly name from its technical name
1691 $valuetoshow = ucfirst($value); // Par default
1692 $valuetoshow = $langs->trans($valuetoshow); // try to translate
1693 $class = '';
1694
1695 if ($value == 'pos') {
1696 $valuetoshow = $langs->trans("Position");
1697 $class = 'right';
1698 }
1699 if ($value == 'source') {
1700 $valuetoshow = $langs->trans("Contact");
1701 }
1702 if ($value == 'price') {
1703 $valuetoshow = $langs->trans("PriceUHT");
1704 }
1705 if ($value == 'taux') {
1706 if ($tabname[$id] != "c_revenuestamp") {
1707 $valuetoshow = $langs->trans("Rate");
1708 } else {
1709 $valuetoshow = $langs->trans("Amount");
1710 }
1711 $class = 'center';
1712 }
1713 if ($value == 'localtax1_type') {
1714 $valuetoshow = $langs->trans("UseLocalTax")." 2";
1715 $class = "center";
1716 $sortable = 0;
1717 }
1718 if ($value == 'localtax1') {
1719 $valuetoshow = $langs->trans("RateOfTaxN", '2');
1720 $class = "center minwidth75";
1721 }
1722 if ($value == 'localtax2_type') {
1723 $valuetoshow = $langs->trans("UseLocalTax")." 3";
1724 $class = "center";
1725 $sortable = 0;
1726 }
1727 if ($value == 'localtax2') {
1728 $valuetoshow = $langs->trans("RateOfTaxN", '3');
1729 $class = "center minwidth75";
1730 }
1731 if ($value == 'type_vat') {
1732 $valuetoshow = $langs->trans("VATType");
1733 }
1734 if ($value == 'organization') {
1735 $valuetoshow = $langs->trans("Organization");
1736 }
1737 if ($value == 'lang') {
1738 $valuetoshow = $langs->trans("Language");
1739 }
1740 if ($value == 'type') {
1741 if ($tabname[$id] == "c_paiement") {
1742 $valuetoshow = $form->textwithtooltip($langs->trans("Type"), $langs->trans("TypePaymentDesc"), 2, 1, img_help(1, ''));
1743 } else {
1744 $valuetoshow = $langs->trans("Type");
1745 }
1746 }
1747 if ($value == 'code') {
1748 $valuetoshow = $langs->trans("Code");
1749 $class = 'maxwidth100';
1750 }
1751 if ($value == 'libelle' || $value == 'label') {
1752 $valuetoshow = $form->textwithtooltip($langs->trans("Label"), $langs->trans("LabelUsedByDefault"), 2, 1, img_help(1, ''));
1753 }
1754 if ($value == 'libelle_facture') {
1755 $valuetoshow = $form->textwithtooltip($langs->trans("LabelOnDocuments"), $langs->trans("LabelUsedByDefault"), 2, 1, img_help(1, ''));
1756 }
1757 if ($value == 'deposit_percent') {
1758 $valuetoshow = $langs->trans('DepositPercent');
1759 $class = 'right';
1760 }
1761 if ($value == 'country') {
1762 if (in_array('region_id', $fieldlist)) {
1763 //print '<td>&nbsp;</td>';
1764 continue;
1765 } // For region page, we do not show the country input
1766 $valuetoshow = $langs->trans("Country");
1767 }
1768 if ($value == 'department_buyer') {
1769 $valuetoshow = '';
1770 }
1771 if ($value == 'recuperableonly') {
1772 $valuetoshow = $langs->trans("NPR");
1773 $class = "center";
1774 }
1775 if ($value == 'einvoice_vatex') {
1776 $valuetoshow = $langs->trans("VATExemptionCode");
1777 $class = "center";
1778 }
1779 if ($value == 'nbjour') {
1780 $valuetoshow = $langs->trans("NbOfDays");
1781 $class = 'right';
1782 }
1783 if ($value == 'type_cdr') {
1784 $valuetoshow = $langs->trans("AtEndOfMonth");
1785 $class = "center";
1786 }
1787 if ($value == 'decalage') {
1788 $valuetoshow = $langs->trans("Offset");
1789 $class = 'right';
1790 }
1791 if ($value == 'width' || $value == 'nx') {
1792 $valuetoshow = $langs->trans("Width");
1793 }
1794 if ($value == 'height' || $value == 'ny') {
1795 $valuetoshow = $langs->trans("Height");
1796 }
1797 if ($value == 'unit' || $value == 'metric') {
1798 $valuetoshow = $langs->trans("MeasuringUnit");
1799 }
1800 if ($value == 'region_id' || $value == 'country_id' || $value == 'department_buyer_id') {
1801 $valuetoshow = '';
1802 }
1803 if ($value == 'accountancy_code') {
1804 $valuetoshow = $langs->trans("AccountancyCode");
1805 }
1806 if ($value == 'accountancy_code_sell') {
1807 $valuetoshow = $langs->trans("AccountancyCodeSell");
1808 }
1809 if ($value == 'accountancy_code_buy') {
1810 $valuetoshow = $langs->trans("AccountancyCodeBuy");
1811 }
1812 if ($value == 'pcg_version' || $value == 'fk_pcg_version') {
1813 $valuetoshow = $langs->trans("Pcg_version");
1814 }
1815 if ($value == 'account_parent') {
1816 $valuetoshow = $langs->trans("Accountparent");
1817 }
1818 if ($value == 'pcg_type') {
1819 $valuetoshow = $langs->trans("Pcg_type");
1820 }
1821 if ($value == 'pcg_subtype') {
1822 $valuetoshow = $langs->trans("Pcg_subtype");
1823 }
1824 if ($value == 'sortorder') {
1825 $valuetoshow = $langs->trans("SortOrder");
1826 $class = 'center';
1827 }
1828 if ($value == 'short_label') {
1829 $valuetoshow = $langs->trans("ShortLabel");
1830 }
1831 if ($value == 'fk_parent') {
1832 $valuetoshow = $langs->trans("ParentID");
1833 $class = 'center';
1834 }
1835 if ($value == 'range_account') {
1836 $valuetoshow = $langs->trans("Range");
1837 }
1838 if ($value == 'sens') {
1839 $valuetoshow = $langs->trans("Sens");
1840 }
1841 if ($value == 'category_type') {
1842 $valuetoshow = $langs->trans("Calculated");
1843 }
1844 if ($value == 'formula') {
1845 $valuetoshow = $langs->trans("Formula");
1846 }
1847 if ($value == 'paper_size') {
1848 $valuetoshow = $langs->trans("PaperSize");
1849 }
1850 if ($value == 'orientation') {
1851 $valuetoshow = $langs->trans("Orientation");
1852 }
1853 if ($value == 'leftmargin') {
1854 $valuetoshow = $langs->trans("LeftMargin");
1855 }
1856 if ($value == 'topmargin') {
1857 $valuetoshow = $langs->trans("TopMargin");
1858 }
1859 if ($value == 'spacex') {
1860 $valuetoshow = $langs->trans("SpaceX");
1861 }
1862 if ($value == 'spacey') {
1863 $valuetoshow = $langs->trans("SpaceY");
1864 }
1865 if ($value == 'font_size') {
1866 $valuetoshow = $langs->trans("FontSize");
1867 }
1868 if ($value == 'custom_x') {
1869 $valuetoshow = $langs->trans("CustomX");
1870 }
1871 if ($value == 'custom_y') {
1872 $valuetoshow = $langs->trans("CustomY");
1873 }
1874 if ($value == 'percent') {
1875 $valuetoshow = $langs->trans("Percentage");
1876 }
1877 if ($value == 'affect') {
1878 $valuetoshow = $langs->trans("WithCounter");
1879 }
1880 if ($value == 'delay') {
1881 $valuetoshow = $langs->trans("NoticePeriod");
1882 }
1883 if ($value == 'newbymonth') {
1884 $valuetoshow = $langs->trans("NewByMonth");
1885 }
1886 if ($value == 'fk_tva') {
1887 $valuetoshow = $langs->trans("VAT");
1888 }
1889 if ($value == 'range_ik') {
1890 $valuetoshow = $langs->trans("RangeIk");
1891 }
1892 if ($value == 'fk_c_exp_tax_cat') {
1893 $valuetoshow = $langs->trans("CarCategory");
1894 }
1895 if ($value == 'revenuestamp_type') {
1896 $valuetoshow = $langs->trans('TypeOfRevenueStamp');
1897 }
1898 if ($value == 'use_default') {
1899 $valuetoshow = $langs->trans('Default');
1900 $class = 'center';
1901 }
1902 if ($value == 'unit_type') {
1903 $valuetoshow = $langs->trans('TypeOfUnit');
1904 }
1905 if ($value == 'public' && $tablib[$id] == 'TicketDictCategory') {
1906 $valuetoshow = $langs->trans('TicketGroupIsPublic');
1907 $class = 'center';
1908 }
1909 if ($value == 'block_if_negative') {
1910 $valuetoshow = $langs->trans('BlockHolidayIfNegative');
1911 }
1912 if ($value == 'type_duration') {
1913 $valuetoshow = $langs->trans('Unit');
1914 }
1915
1916 if ($id == DICT_DEPARTEMENTS) { // Special case for state page
1917 if ($value == 'region_id') {
1918 $valuetoshow = '&nbsp;';
1919 $showfield = 1;
1920 }
1921 if ($value == 'region') {
1922 $valuetoshow = $langs->trans("Country").'/'.$langs->trans("Region");
1923 $showfield = 1;
1924 }
1925 }
1926
1927 if ($valuetoshow != '') {
1928 $tooltiphelp = (isset($tabcomplete[$tabname[$id]]['help'][$value]) ? $tabcomplete[$tabname[$id]]['help'][$value] : '');
1929
1930 $tdsoffields .= '<th'.($class ? ' class="'.$class.'"' : '').'>';
1931 if ($tooltiphelp && preg_match('/^http(s*):/i', $tooltiphelp)) {
1932 $tdsoffields .= '<a href="'.$tooltiphelp.'" target="_blank">'.$valuetoshow.' '.img_help(1, $valuetoshow).'</a>';
1933 } elseif ($tooltiphelp) {
1934 $tdsoffields .= $form->textwithpicto($valuetoshow, $tooltiphelp);
1935 } else {
1936 $tdsoffields .= $valuetoshow;
1937 }
1938 $tdsoffields .= '</th>';
1939 }
1940 }
1941
1942 if ($id == DICT_COUNTRY) {
1943 $tdsoffields .= '<th></th>';
1944 $tdsoffields .= '<th></th>';
1945 }
1946 $tdsoffields .= '<th>';
1947 $tdsoffields .= '<input type="hidden" name="id" value="'.$id.'">';
1948 if (!is_null($withentity)) {
1949 $tdsoffields .= '<input type="hidden" name="entity" value="'.$withentity.'">';
1950 }
1951 $tdsoffields .= '</th>';
1952 $tdsoffields .= '<th style="min-width: 26px;"></th>';
1953 $tdsoffields .= '<th style="min-width: 26px;"></th>';
1954 $tdsoffields .= '</tr>';
1955
1956 print $tdsoffields;
1957
1958
1959 // Line to enter new values
1960 print '<!-- line input to add new entry -->';
1961 print '<tr class="oddeven nodrag nodrop nohover">';
1962
1963 $obj = new stdClass();
1964 // If data was already input, we define them in obj to populate input fields.
1965 if (GETPOST('actionadd')) {
1966 foreach ($fieldlist as $key => $val) {
1967 if (GETPOST($val) != '') {
1968 $obj->$val = GETPOST($val);
1969 }
1970 }
1971 }
1972
1973 $tmpaction = 'create';
1974 $parameters = array('fieldlist' => $fieldlist, 'tabname' => $tabname[$id]);
1975 $reshook = $hookmanager->executeHooks('createDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
1976 $error = $hookmanager->error;
1977 $errors = $hookmanager->errors;
1978
1979 if ($id == DICT_REGIONS) {
1980 unset($fieldlist[2]); // Remove field ??? if dictionary Regions
1981 }
1982
1983 if (empty($reshook)) {
1984 dictFieldList($fieldlist, $obj, $tabname[$id], 'add');
1985 }
1986
1987 if ($id == DICT_COUNTRY) {
1988 print '<td></td>';
1989 print '<td></td>';
1990 print '<td></td>';
1991 }
1992 print '<td colspan="3" class="center">';
1993 if ($action != 'edit') {
1994 print '<input type="submit" class="button button-add small" name="actionadd" value="'.$langs->trans("Add").'">';
1995 } else {
1996 print '<input type="submit" class="button button-add small disabled" name="actionadd" value="'.$langs->trans("Add").'">';
1997 }
1998 print '</td>';
1999
2000 print "</tr>";
2001
2002 print '</table>';
2003 print '</div>';
2004 }
2005
2006 print '</form>';
2007
2008 print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$id.'" method="POST" spellcheck="false">';
2009 print '<input type="hidden" name="token" value="'.newToken().'">';
2010 print '<input type="hidden" name="from" value="'.dol_escape_htmltag(GETPOST('from', 'alpha')).'">';
2011 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
2012 }
2013
2014
2015 // Selection of columns to show (this also update the array $arrayfields with the setup of user)
2016 $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $contextpage, $conf->main_checkbox_left_column, 0);
2017
2018 $filterfound = 0;
2019 foreach ($fieldlist as $field => $value) {
2020 if ($value == 'entity') {
2021 continue;
2022 }
2023
2024 $showfield = 1; // By default
2025 if ($value == 'region_id' || $value == 'country_id' || $value == 'department_buyer_id') {
2026 $showfield = 0;
2027 }
2028 if (empty($arrayfields[$value]['checked'])) {
2029 $showfield = 0; // Column was not selected to be displayed
2030 }
2031
2032 if ($showfield) {
2033 if ($value == 'country') {
2034 $filterfound++;
2035 } elseif ($value == 'code') {
2036 $filterfound++;
2037 }
2038 }
2039 }
2040
2041 print '<div class="div-table-responsive">';
2042 print '<table class="noborder centpercent noborder">';
2043
2044 $colspan = 0;
2045
2046 // Title line with search input fields
2047 print '<!-- line title to search record -->'."\n";
2048 print '<tr class="liste_titre_filter">';
2049
2050 // Action button
2051 if ($conf->main_checkbox_left_column) {
2052 print '<td class="liste_titre center maxwidthsearch">';
2053 if ($filterfound) {
2054 $searchpicto = $form->showFilterAndCheckAddButtons(0);
2055 print $searchpicto;
2056 }
2057 print '</td>';
2058 $colspan++;
2059 }
2060
2061 foreach ($fieldlist as $field => $value) {
2062 if ($value == 'entity') {
2063 continue;
2064 }
2065
2066 $showfield = 1; // By default
2067 if ($value == 'region_id' || $value == 'country_id' || $value == 'department_buyer_id') {
2068 $showfield = 0;
2069 }
2070 if (empty($arrayfields[$value]['checked'])) {
2071 $showfield = 0; // Column was not selected to be displayed
2072 }
2073
2074 if ($showfield) {
2075 if ($value == 'country') {
2076 print '<td class="liste_titre">';
2077 print $form->select_country($search_country_id, 'search_country_id', '', 28, 'minwidth100 maxwidth150 maxwidthonsmartphone', '', '&nbsp;');
2078 print '</td>';
2079 $colspan++;
2080 } elseif ($value == 'code') {
2081 print '<td class="liste_titre">';
2082 print '<input type="text" class="maxwidth100" name="search_code" value="'.dol_escape_htmltag($search_code).'">';
2083 print '</td>';
2084 $colspan++;
2085 } elseif ($value == 'type_vat') {
2086 print '<td class="liste_titre">';
2087 print $form->selectarray('search_'.$value, $type_vatList, (empty($obj->{$value}) ? '' : $obj->{$value}), 1);
2088 print '</td>';
2089 $colspan++;
2090 } else {
2091 print '<td class="liste_titre">';
2092 print '</td>';
2093 $colspan++;
2094 }
2095 }
2096 }
2097 if ($id == DICT_COUNTRY) {
2098 print '<td></td>';
2099 $colspan++;
2100 print '<td></td>';
2101 $colspan++;
2102 print '<td></td>';
2103 $colspan++;
2104 }
2105
2106 // Active
2107 print '<td class="liste_titre center parentonrightofpage">';
2108 print $form->selectyesno('search_active', $search_active, 0, false, 1, 1, 'maxwidth100 onrightofpage', 'Activated', 'Disabled');
2109 print '</td>';
2110 $colspan++;
2111
2112 // Action button
2113 if (!$conf->main_checkbox_left_column) {
2114 print '<td class="liste_titre center maxwidthsearch">';
2115 if ($filterfound) {
2116 $searchpicto = $form->showFilterAndCheckAddButtons(0);
2117 print $searchpicto;
2118 }
2119 print '</td>';
2120 $colspan++;
2121 }
2122
2123 print '</tr>';
2124
2125
2126 // Title of lines
2127 print '<!-- line title of record -->'."\n";
2128 print '<tr class="liste_titre">';
2129
2130 // Action button
2131 if ($conf->main_checkbox_left_column) {
2132 print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', ($page ? 'page='.$page.'&' : ''), $param, '', $sortfield, $sortorder, 'center maxwidthsearch ');
2133 }
2134
2135 foreach ($fieldlist as $field => $value) {
2136 if ($value == 'entity') {
2137 continue;
2138 }
2139
2140 if (in_array($value, array('label', 'libelle', 'libelle_facture')) && empty($tabcomplete[$tabname[$id]]['help'][$value])) {
2141 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
2142 $tabcomplete[$tabname[$id]]['help'] = array();
2143 }
2144 $tabcomplete[$tabname[$id]]['help'][$value] = $langs->trans('LabelUsedByDefault');
2145 }
2146
2147 // Determines the name of the field in relation to the possible names
2148 // in data dictionaries
2149 $showfield = 1; // By default
2150 $cssprefix = '';
2151 $sortable = 1;
2152 $valuetoshow = dictFieldLabel($value, $tabname[$id], $tablib[$id]); // Label of the column
2153
2154 // Special cases for the CSS of the column or to disable the sort
2155 if ($value == 'taux') {
2156 $cssprefix = 'center ';
2157 }
2158 if (in_array($value, array('type_vat', 'localtax1_type', 'localtax1', 'localtax2_type', 'localtax2'))) {
2159 $cssprefix = "center minwidth75 ";
2160 $sortable = 0;
2161 }
2162 if (in_array($value, array('pos', 'position', 'deposit_percent', 'nbjour', 'decalage'))) {
2163 $cssprefix = 'right ';
2164 }
2165 if ($value == 'recuperableonly') {
2166 $cssprefix = "center ";
2167 }
2168 if ($value == 'einvoice_vatex') {
2169 $cssprefix = "center";
2170 }
2171 if ($value == 'type_cdr') {
2172 $cssprefix = "center ";
2173 }
2174 if ($value == 'accountancy_code_sell' || $value == 'accountancy_code_buy') {
2175 $sortable = 0;
2176 }
2177 if (in_array($value, array('sortorder', 'fk_parent', 'use_default'))) {
2178 $cssprefix = 'center ';
2179 }
2180 if ($value == 'public' && $tablib[$id] == 'TicketDictCategory') {
2181 $cssprefix = 'center ';
2182 }
2183
2184 if ($value == 'region_id' || $value == 'country_id' || $value == 'department_buyer_id') {
2185 $showfield = 0;
2186 }
2187 if (empty($arrayfields[$value]['checked'])) {
2188 $showfield = 0; // Column was not selected to be displayed
2189 }
2190
2191 // Show field title
2192 if ($showfield) {
2193 $tooltiphelp = (isset($tabcomplete[$tabname[$id]]['help'][$value]) ? $tabcomplete[$tabname[$id]]['help'][$value] : '');
2194
2195 if ($tooltiphelp && preg_match('/^http(s*):/i', $tooltiphelp)) {
2196 $newvaluetoshow = '<a href="'.$tooltiphelp.'" target="_blank">'.$valuetoshow.' '.img_help(1, $valuetoshow).'</a>';
2197 } elseif ($tooltiphelp) {
2198 $newvaluetoshow = $form->textwithpicto($valuetoshow, $tooltiphelp);
2199 } else {
2200 $newvaluetoshow = $valuetoshow;
2201 }
2202
2203 print getTitleFieldOfList($newvaluetoshow, 0, $_SERVER["PHP_SELF"], ($sortable ? $value : ''), ($page ? 'page='.$page.'&' : ''), $param, '', $sortfield, $sortorder, $cssprefix);
2204 }
2205 }
2206 // Favorite, EEC & Sepa - Only activated on country dictionary
2207 if ($id == DICT_COUNTRY) {
2208 print getTitleFieldOfList($langs->trans("InEEC"), 0, $_SERVER["PHP_SELF"], "eec", ($page ? 'page='.$page.'&' : ''), $param, '', $sortfield, $sortorder, 'center ', 0, $langs->trans("CountryIsInEEC"));
2209 print getTitleFieldOfList($langs->trans("InSepa"), 0, $_SERVER["PHP_SELF"], "sepa", ($page ? 'page='.$page.'&' : ''), $param, '', $sortfield, $sortorder, 'center ', 0, $langs->trans("CountryIsInSepa"));
2210 print getTitleFieldOfList($langs->trans("Favorite"), 0, $_SERVER["PHP_SELF"], "favorite", ($page ? 'page='.$page.'&' : ''), $param, '', $sortfield, $sortorder, 'center ');
2211 }
2212
2213 // Status
2214 print getTitleFieldOfList($langs->trans("Status"), 0, $_SERVER["PHP_SELF"], "active", ($page ? 'page='.$page.'&' : ''), $param, '', $sortfield, $sortorder, 'center ');
2215
2216 // Action button
2217 if (!$conf->main_checkbox_left_column) {
2218 print getTitleFieldOfList($selectedfields);
2219 }
2220 print '</tr>';
2221
2222
2223 // Lines with values
2224 if ($num) {
2225 print '<!-- lines of dict -->'."\n";
2226 while ($i < $num) {
2227 $obj = $db->fetch_object($resql);
2228
2229 // Entity owning this row, when the dictionary is entity aware (the SELECT of
2230 // $tabsql must then include the entity column). It is used to target the right row
2231 // on write, and to tell rows of another entity apart just below.
2232 $withentity = (isset($obj->entity) ? (int) $obj->entity : null);
2233
2234 // We discard empty lines
2235 if ($id == DICT_COUNTRY) {
2236 if ($obj->code == '') {
2237 $i++;
2238 continue;
2239 }
2240 }
2241
2242 // Can an entry be erased, disabled or modified ? (true by default)
2243 $iserasable = 1;
2244 $canbedisabled = 1;
2245 $canbemodified = 1;
2246 if (isset($obj->code) && !in_array($id, array(DICT_TVA, DICT_PRODUCT_NATURE))) {
2247 if (($obj->code == '0' || $obj->code == '' || preg_match('/unknown/i', $obj->code))) {
2248 $iserasable = 0;
2249 $canbedisabled = 0;
2250 } elseif ($obj->code == 'RECEP') {
2251 $iserasable = 0;
2252 $canbedisabled = 0;
2253 } elseif ($obj->code == 'EF0') {
2254 $iserasable = 0;
2255 $canbedisabled = 0;
2256 }
2257 }
2258 if ($id == DICT_TYPE_CONTAINER && $obj->module == 'system') {
2259 $iserasable = 0;
2260 $canbedisabled = 0;
2261 if (in_array($obj->code, array('banner'))) {
2262 $canbedisabled = 1;
2263 }
2264 }
2265 if (isset($obj->type) && in_array($obj->type, array('system', 'systemauto'))) {
2266 $iserasable = 0;
2267 }
2268 if (in_array(empty($obj->code) ? '' : $obj->code, array('AC_OTH', 'AC_OTH_AUTO')) || in_array(empty($obj->type) ? '' : $obj->type, array('systemauto'))) {
2269 $canbedisabled = 0;
2270 $canbedisabled = 0;
2271 }
2272 $canbemodified = $iserasable;
2273
2274 if (!empty($obj->code) && $obj->code == 'RECEP') {
2275 $canbemodified = 1;
2276 }
2277 if ($tabname[$id] == "c_actioncomm") {
2278 $canbemodified = 1;
2279 }
2280
2281 if ($tabname[$id] == "c_product_nature" && in_array($obj->code, array(0, 1))) {
2282 $canbedisabled = 0;
2283 $canbemodified = 0;
2284 $iserasable = 0;
2285 }
2286
2287 // A row owned by another entity is read-only here. This happens when a dictionary
2288 // is shared with the current entity (for instance the dictionary of the master
2289 // entity that this entity only extends, with module multicompany): the row is
2290 // legitimately listed, but editing it would change it for the other entity too.
2291 // Without multicompany, getEntity() returns the current entity and every listed row
2292 // belongs to it, so this never triggers.
2293 if (!is_null($withentity) && $withentity != (int) getEntity($tabname[$id], 0)) {
2294 $iserasable = 0;
2295 $canbedisabled = 0;
2296 $canbemodified = 0;
2297 }
2298 // Build Url. The table is id=, the id of line is rowid=
2299 $rowidcol = empty($tabrowid[$id]) ? 'rowid' : $tabrowid[$id];
2300 // If rowidcol not defined
2301 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))) {
2302 $rowidcol = 'rowid';
2303 }
2304 $url = $_SERVER["PHP_SELF"].'?'.($page ? 'page='.$page.'&' : '').'sortfield='.urlencode($sortfield).'&sortorder='.urlencode($sortorder);
2305 $url .= '&rowid='.(isset($obj->$rowidcol) ? ((int) $obj->$rowidcol) : (!empty($obj->code) ? urlencode($obj->code) : ''));
2306 $url .= '&code='.(!empty($obj->code) ? urlencode($obj->code) : '');
2307 if (!empty($param)) {
2308 $url .= '&'.$param;
2309 }
2310 // If dictionary is different for each entity
2311 if (!is_null($withentity)) {
2312 $url .= '&entity='.((int) $withentity);
2313 }
2314 $url .= '&';
2315
2316
2317 //print_r($obj);
2318 print '<tr class="oddeven" id="rowid-'.(empty($obj->rowid) ? '' : $obj->rowid).'">';
2319
2320 // Action button
2321 if ($conf->main_checkbox_left_column) {
2322 print '<td class="center maxwidthsearch nowraponall">';
2323 // Modify link
2324 if ($canbemodified) {
2325 print '<a class="reposition editfielda marginleftonly paddingleft marginrightonly paddingright" href="'.$url.'action=edit&token='.newToken().'">'.img_edit().'</a>';
2326 }
2327 // Delete link
2328 if ($iserasable) {
2329 if ($user->admin) {
2330 print '<a class="reposition marginleftonly paddingleft marginrightonly paddingright" href="'.$url.'action=delete&token='.newToken().'">'.img_delete().'</a>';
2331 }
2332 }
2333 print '</td>';
2334 }
2335
2336 // Use isset() rather than !empty() so a dictionary row with rowid = 0
2337 // (for example ST_NEVER in llx_c_stcomm) is treated as a real rowid and
2338 // not fallen back to the code, which would make it un-editable (#38781).
2339 if ($action == 'edit' && ($rowid == (isset($obj->rowid) ? $obj->rowid : $obj->code))) {
2340 $tmpaction = 'edit';
2341 $parameters = array('fieldlist' => $fieldlist, 'tabname' => $tabname[$id]);
2342 $reshook = $hookmanager->executeHooks('editDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
2343 $error = $hookmanager->error;
2344 $errors = $hookmanager->errors;
2345
2346 // Show fields
2347 if (empty($reshook)) {
2348 $withentity = dictFieldList($fieldlist, $obj, $tabname[$id], 'edit');
2349 }
2350
2351 print '<td colspan="3" class="center">';
2352 print '<div name="'.(isset($obj->rowid) ? $obj->rowid : $obj->code).'"></div>';
2353 print '<input type="hidden" name="page" value="'.((int) $page).'">';
2354 print '<input type="hidden" name="rowid" value="'.dol_escape_htmltag($rowid).'">';
2355 if (!is_null($withentity)) {
2356 print '<input type="hidden" name="entity" value="'.$withentity.'">';
2357 }
2358 print '<input type="submit" class="button button-edit smallpaddingimp" name="actionmodify" value="'.$langs->trans("Modify").'">';
2359 print '<input type="submit" class="button button-cancel smallpaddingimp" name="actioncancel" value="'.$langs->trans("Cancel").'">';
2360 print '</td>';
2361 } else {
2362 $tmpaction = 'view';
2363 $parameters = array('fieldlist' => $fieldlist, 'tabname' => $tabname[$id]);
2364 $reshook = $hookmanager->executeHooks('viewDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
2365
2366 $error = $hookmanager->error;
2367 $errors = $hookmanager->errors;
2368
2369 $langs->loadLangs(array("bills", "agenda", "propal"));
2370
2371 if (empty($reshook)) {
2372 $withentity = null;
2373 $TDurationTypes = $form->getDurationTypes($langs);
2374
2375 foreach ($fieldlist as $field => $value) {
2376 $class = (isset($tabcomplete[$tabname[$id]]['css'][$value]) ? $tabcomplete[$tabname[$id]]['css'][$value] : '');
2377 $showfield = 1;
2378 if (empty($arrayfields[$value]['checked'])) {
2379 $showfield = 0; // Column was not selected to be displayed
2380 }
2381 $valuetoshow = (isset($obj->$value) && $obj->$value !== null && $obj->$value !== '') ? $obj->$value : '';
2382 $titletoshow = '';
2383
2384 if ($value == 'entity') {
2385 $withentity = $valuetoshow;
2386 continue;
2387 }
2388
2389 // Management of several special cases and exceptions
2390 if ($value == 'code' && $id == DICT_PRODUCT_NATURE) {
2391 $valuetoshow = (int) $valuetoshow;
2392 } elseif ($value == 'element') {
2393 $valuetoshow = isset($elementList[$valuetoshow]) ? $elementList[$valuetoshow] : $valuetoshow;
2394 } elseif ($value == 'source') {
2395 $valuetoshow = isset($sourceList[$valuetoshow]) ? $sourceList[$valuetoshow] : $valuetoshow;
2396 } elseif ($valuetoshow == 'all') {
2397 $valuetoshow = $langs->trans('All');
2398 } elseif ($value == 'country') {
2399 if (empty($obj->country_code)) {
2400 $valuetoshow = '-';
2401 } else {
2402 $key = $langs->trans("Country".strtoupper($obj->country_code));
2403 $valuetoshow = ($key != "Country".strtoupper($obj->country_code) ? $obj->country_code." - ".$key : $obj->country);
2404 }
2405 } elseif ($value == 'recuperableonly' || $value == 'deductible' || $value == 'category_type') {
2406 $valuetoshow = yn($valuetoshow ? 1 : 0);
2407 $class = "center";
2408 } elseif ($value == 'type_cdr') {
2409 if (empty($valuetoshow)) {
2410 $valuetoshow = $langs->trans('None');
2411 } elseif ($valuetoshow == 1) {
2412 $valuetoshow = $langs->trans('AtEndOfMonth');
2413 } elseif ($valuetoshow == 2) {
2414 $valuetoshow = $langs->trans('CurrentNext');
2415 }
2416 $class = "center tdoverflowmax125";
2417 } elseif ($value == 'price' || preg_match('/^amount/i', $value)) {
2418 $valuetoshow = price($valuetoshow);
2419 }
2420 if (in_array($value, array('private', 'joinfile', 'use_default'))) {
2421 if (!empty($valuetoshow)) {
2422 $valuetoshow = img_picto('', 'tick');
2423 } else {
2424 $valuetoshow = '';
2425 }
2426 } elseif ($value == 'libelle_facture') {
2427 $key = $langs->trans("PaymentCondition".strtoupper($obj->code));
2428 $valuetoshow = ($obj->code && $key != "PaymentCondition".strtoupper($obj->code) ? $key : $obj->$value);
2429 $valuetoshow = nl2br($valuetoshow);
2430 $titletoshow = $valuetoshow;
2431 $class = 'small tdoverflowmax200';
2432 } elseif ($value == 'label' && $tabname[$id] == 'c_country') {
2433 $key = $langs->trans("Country".strtoupper($obj->code));
2434 $valuetoshow = ($obj->code && $key != "Country".strtoupper($obj->code) ? $key : $obj->$value);
2435 } elseif ($value == 'label' && $tabname[$id] == 'c_availability') {
2436 $key = $langs->trans("AvailabilityType".strtoupper($obj->code));
2437 $valuetoshow = ($obj->code && $key != "AvailabilityType".strtoupper($obj->code) ? $key : $obj->$value);
2438 } elseif ($value == 'libelle' && $tabname[$id] == 'c_actioncomm') {
2439 $key = $langs->trans("Action".strtoupper($obj->code));
2440 $valuetoshow = ($obj->code && $key != "Action".strtoupper($obj->code) ? $key : $obj->$value);
2441 } elseif (!empty($obj->code_iso) && $value == 'label' && $tabname[$id] == 'c_currencies') {
2442 $key = $langs->trans("Currency".strtoupper($obj->code_iso));
2443 $valuetoshow = (/* $obj->code_iso && */ $key != "Currency".strtoupper($obj->code_iso) ? $key : $obj->$value);
2444 } elseif ($value == 'libelle' && $tabname[$id] == 'c_typent') {
2445 $key = $langs->trans(strtoupper($obj->code));
2446 $valuetoshow = ($key != strtoupper($obj->code) ? $key : $obj->$value);
2447 } elseif ($value == 'libelle' && $tabname[$id] == 'c_prospectlevel') {
2448 $key = $langs->trans(strtoupper($obj->code));
2449 $valuetoshow = ($key != strtoupper($obj->code) ? $key : $obj->$value);
2450 } elseif ($value == 'label' && $tabname[$id] == 'c_civility') {
2451 $key = $langs->trans("Civility".strtoupper($obj->code));
2452 $valuetoshow = ($obj->code && $key != "Civility".strtoupper($obj->code) ? $key : $obj->$value);
2453 } elseif ($value == 'libelle' && $tabname[$id] == 'c_type_contact') {
2454 $key = $langs->trans("TypeContact_".$obj->element."_".$obj->source."_".strtoupper($obj->code));
2455 $valuetoshow = ($obj->code && $key != "TypeContact_".$obj->element."_".$obj->source."_".strtoupper($obj->code) ? $key : $obj->$value);
2456 } elseif ($value == 'libelle' && $tabname[$id] == 'c_payment_term') {
2457 $key = $langs->trans("PaymentConditionShort".strtoupper($obj->code));
2458 $valuetoshow = ($obj->code && $key != "PaymentConditionShort".strtoupper($obj->code) ? $key : $obj->$value);
2459 $titletoshow = $key;
2460 $class = "tdoverflowmax150";
2461 } elseif ($value == 'libelle' && $tabname[$id] == 'c_paiement') {
2462 $key = $langs->trans("PaymentType".strtoupper($obj->code));
2463 $valuetoshow = $obj->$value;
2464 if ($obj->code && array_key_exists("PaymentType".strtoupper($obj->code), $langs->tab_translate)) {
2465 $htmltext = $form->textwithpicto($langs->trans("TranslationFound").': '.$key, $langs->trans("TheTranslationIsSearchedFromKey", "PaymentType".strtoupper($obj->code)));
2466 } else {
2467 $htmltext = $form->textwithpicto($langs->trans("TranslationFound").': '.$langs->trans("No"), $langs->trans("TheTranslationIsSearchedFromKey", "PaymentType".strtoupper($obj->code)));
2468 }
2469 //$valuetoshow = $form->textwithpicto($valuetoshow, $htmltext);
2470 $valuetoshow .= '<br><span class="opacitymedium small">'.$htmltext.'</span>';
2471 } elseif ($value == 'type' && $tabname[$id] == 'c_paiement') {
2472 $payment_type_list = array(0 => $langs->trans('PaymentTypeCustomer'), 1 => $langs->trans('PaymentTypeSupplier'), 2 => $langs->trans('PaymentTypeBoth'));
2473 $valuetoshow = $payment_type_list[$valuetoshow];
2474 } elseif ($value == 'label' && $tabname[$id] == 'c_input_reason') {
2475 $key = $langs->trans("DemandReasonType".strtoupper($obj->code));
2476 $valuetoshow = ($obj->code && $key != "DemandReasonType".strtoupper($obj->code) ? $key : $obj->$value);
2477 } elseif ($value == 'libelle' && $tabname[$id] == 'c_input_method') {
2478 $langs->load("orders");
2479 $key = $langs->trans($obj->code);
2480 $valuetoshow = ($obj->code && $key != $obj->code) ? $key : $obj->$value;
2481 } elseif ($value == 'libelle' && $tabname[$id] == 'c_shipment_mode') {
2482 $langs->load("sendings");
2483 $key = $langs->trans("SendingMethod".strtoupper($obj->code));
2484 $valuetoshow = ($obj->code && $key != "SendingMethod".strtoupper($obj->code) ? $key : $obj->$value);
2485 } elseif ($value == 'libelle' && $tabname[$id] == 'c_paper_format') {
2486 $key = $langs->trans('PaperFormat'.strtoupper($obj->code));
2487 $valuetoshow = ($obj->code && $key != 'PaperFormat'.strtoupper($obj->code) ? $key : $obj->$value);
2488 } elseif ($value == 'label' && $tabname[$id] == 'c_type_fees') {
2489 $langs->load('trips');
2490 $key = $langs->trans(strtoupper($obj->code));
2491 $valuetoshow = ($obj->code && $key != strtoupper($obj->code) ? $key : $obj->$value);
2492 } elseif ($value == 'region_id' || $value == 'country_id' || $value == 'department_buyer_id') {
2493 $showfield = 0;
2494 } elseif ($value == 'unicode') {
2495 $valuetoshow = $langs->getCurrencySymbol($obj->code, 1);
2496 } elseif ($value == 'label' && $tabname[GETPOSTINT("id")] == 'c_units') {
2497 $langs->load("products");
2498 $valuetoshow = $langs->trans($obj->$value);
2499 } elseif ($value == 'short_label' && $tabname[GETPOSTINT("id")] == 'c_units') {
2500 $langs->load("products");
2501 $valuetoshow = $langs->trans($obj->$value);
2502 } elseif (($value == 'unit') && ($tabname[$id] == 'c_paper_format')) {
2503 $key = $langs->trans('SizeUnit'.strtolower($obj->unit));
2504 $valuetoshow = ($obj->code && $key != 'SizeUnit'.strtolower($obj->unit) ? $key : $obj->$value);
2505 } elseif ($value == 'localtax1' || $value == 'localtax2') {
2506 $class = "center";
2507 } elseif ($value == 'type_vat') {
2508 $valuetoshow = $type_vatList[(int) $valuetoshow];
2509 $class = "center";
2510 } elseif ($value == 'localtax1_type') {
2511 if ($obj->localtax1 != 0) {
2512 $valuetoshow = $localtax_typeList[$valuetoshow];
2513 } else {
2514 $valuetoshow = '';
2515 }
2516 $class = "center";
2517 } elseif ($value == 'localtax2_type') {
2518 if ($obj->localtax2 != 0) {
2519 $valuetoshow = $localtax_typeList[$valuetoshow];
2520 } else {
2521 $valuetoshow = '';
2522 }
2523 $class = "center";
2524 } elseif ($value == 'taux') {
2525 $valuetoshow = price($valuetoshow, 0, $langs, 0, 0);
2526 $class = "center";
2527 } elseif (in_array($value, array('recuperableonly'))) {
2528 $class = "center";
2529 } elseif ($value == 'accountancy_code' || $value == 'accountancy_code_sell' || $value == 'accountancy_code_buy') {
2530 if (isModEnabled('accounting')) {
2531 require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php';
2532 $tmpaccountingaccount = new AccountingAccount($db);
2533 $tmpaccountingaccount->fetch(0, $valuetoshow, 1);
2534 $titletoshow = $langs->transnoentitiesnoconv("Pcgtype").': '.$tmpaccountingaccount->pcg_type;
2535 }
2536 $valuetoshow = length_accountg($valuetoshow);
2537 } elseif ($value == 'fk_tva') {
2538 if (empty($form->cache_vatrates)) {
2539 $form->load_tva('cache_fk_tva', '', $mysoc, new Societe($db), 0, 0, '', false, -1);
2540 }
2541 foreach ($form->cache_vatrates as $key => $Tab) {
2542 if ($form->cache_vatrates[$key]['rowid'] == $valuetoshow) {
2543 $valuetoshow = $form->cache_vatrates[$key]['label'];
2544 break;
2545 }
2546 }
2547 } elseif ($value == 'fk_c_exp_tax_cat') {
2548 $tmpid = $valuetoshow;
2549 $valuetoshow = getDictionaryValue('c_exp_tax_cat', 'label', $tmpid);
2550 $valuetoshow = $langs->trans($valuetoshow ? $valuetoshow : $tmpid);
2551 } elseif ($tabname[$id] == 'c_exp_tax_cat') {
2552 $valuetoshow = $langs->trans($valuetoshow);
2553 } elseif ($value == 'libelle' && ($tabname[$id] == 'c_stcomm' || $tabname[$id] == 'c_stcommcontact')) {
2554 $key = 'StatusProspect'.$obj->rowid;
2555 $trans = $langs->trans($key);
2556 $valuetoshow = ($trans != $key ? $trans : $obj->{$value});
2557 } elseif ($value == 'label' && $tabname[$id] == 'c_units') {
2558 $langs->load('other');
2559 $key = $langs->trans($obj->label);
2560 $valuetoshow = ($obj->label && $key != strtoupper($obj->label) ? $key : $obj->{$value});
2561 } elseif ($value == 'label' && $tabname[$id] == 'c_product_nature') {
2562 $langs->load("products");
2563 $valuetoshow = $langs->trans($obj->{$value});
2564 } elseif ($fieldlist[$field] == 'label' && $tabname[$id] == 'c_productbatch_qcstatus') {
2565 $langs->load("productbatch");
2566 $valuetoshow = $langs->trans($obj->{$value});
2567 } elseif ($value == 'block_if_negative') {
2568 $valuetoshow = yn($obj->{$value});
2569 } elseif ($value == 'icon') {
2570 $valuetoshow = $obj->{$value}." ".img_picto("", preg_replace('/^fa-/', '', $obj->{$value}));
2571 } elseif ($value == 'type_duration') {
2572 if (!empty($obj->{$value}) && array_key_exists($obj->{$value}, $TDurationTypes)) {
2573 $valuetoshow = $TDurationTypes[$obj->{$value}];
2574 }
2575 } elseif (in_array($value, array('leftmargin', 'topmargin', 'spacex', 'spacey', 'width', 'height', 'custom_x', 'custom_y'))) {
2576 $valuetoshow = price2num($valuetoshow);
2577 } elseif ($value == 'type' && $id == DICT_ACTIONCOMM && !empty($obj->module)) {
2578 $titletoshow = $langs->trans("Module").' '.$obj->module;
2579 } elseif ($value == 'color') {
2580 $valuetoshow = $formother->showColor($obj->{$value}, '');
2581 }
2582
2583
2584 // Now we define the CSS
2585 $class .= ($class ? ' ' : '').'tddict';
2586 if ($value == 'name') {
2587 $class .= ' tdoverflowmax200';
2588 }
2589 if ($value == 'note' && $id == DICT_TVA) {
2590 $class .= ' tdoverflowmax200';
2591 }
2592 if (in_array($value, array($value == 'tracking'))) {
2593 $class .= ' tdoverflowauto';
2594 }
2595 if (in_array($value, array('nbjour', 'decalage', 'pos', 'position', 'deposit_percent'))) {
2596 $class .= ' right';
2597 }
2598 if (in_array($value, array('icon', 'type_vat', 'localtax1_type', 'localtax2_type'))) {
2599 $class .= ' nowraponall';
2600 }
2601 if (in_array($value, array('use_default', 'fk_parent', 'sortorder', 'public'))) {
2602 $class .= ' center';
2603 }
2604 if (in_array($value, array('localtax1_type', 'localtax2_type', 'note', 'note_public', 'note_private'))) {
2605 $class .= ' small';
2606 }
2607
2608 // Add val as tooltip if there is a tdoverflow on the cell
2609 if (empty($titletoshow) && preg_match('/tdoverflow/', $class)) {
2610 $titletoshow = $valuetoshow;
2611 }
2612
2613 // Show value for field
2614 if ($showfield) {
2615 print '<!-- field value '. $value .' --><td class="'.$class.'"'.($titletoshow ? ' title="'.dolPrintHTMLForAttribute($titletoshow).'"' : '').'>'.$valuetoshow.'</td>';
2616 }
2617 }
2618
2619 // Favorite, EEC & Sepa
2620 // Only for country dictionary
2621 if ($id == DICT_COUNTRY) {
2622 print '<td class="nowraponall center">';
2623 // Is in EEC
2624 if ($iserasable) {
2625 print '<a class="reposition" href="'.$url.'action='.$acts[$obj->eec].'_eec&token='.newToken().'">'.$actl[$obj->eec].'</a>';
2626 } else {
2627 print '<span class="opacitymedium">'.$langs->trans("AlwaysActive").'</span>';
2628 }
2629 print '</td>';
2630 print '<td class="nowraponall center">';
2631 // Is in Sepa
2632 if ($iserasable) {
2633 print '<a class="reposition" href="'.$url.'action='.$acts[$obj->sepa].'_sepa&token='.newToken().'">'.$actl[$obj->sepa].'</a>';
2634 } else {
2635 print '<span class="opacitymedium">'.$langs->trans("AlwaysActive").'</span>';
2636 }
2637 print '</td>';
2638 print '<td class="nowraponall center">';
2639 // Favorite
2640 if ($iserasable) {
2641 print '<a class="reposition" href="'.$url.'action='.$acts[$obj->favorite].'_favorite&token='.newToken().'">'.$actl[$obj->favorite].'</a>';
2642 } else {
2643 print '<span class="opacitymedium">'.$langs->trans("AlwaysActive").'</span>';
2644 }
2645 print '</td>';
2646 }
2647 }
2648
2649 // Active
2650 print '<td class="nowraponall center">';
2651 if ($canbedisabled) {
2652 print '<a class="reposition" href="'.$url.'action='.$acts[$obj->active].'&token='.newToken().'">'.$actl[$obj->active].'</a>';
2653 } else {
2654 if (in_array($obj->code, array('AC_OTH', 'AC_OTH_AUTO'))) {
2655 print $langs->trans("AlwaysActive");
2656 } elseif (isset($obj->type) && in_array($obj->type, array('systemauto')) && empty($obj->active)) {
2657 print $langs->trans("Deprecated");
2658 } elseif (isset($obj->type) && in_array($obj->type, array('system')) && !empty($obj->active) && $obj->code != 'AC_OTH') {
2659 print $langs->trans("UsedOnlyWithTypeOption");
2660 } else {
2661 print '<span class="opacitymedium">'.$langs->trans("AlwaysActive").'</span>';
2662 }
2663 }
2664 print "</td>";
2665
2666 // Action button
2667 if (!$conf->main_checkbox_left_column) {
2668 print '<td class="center maxwidthsearch nowraponall">';
2669 // Modify link
2670 if ($canbemodified) {
2671 print '<a class="reposition marginleftonly paddingleft marginrightonly paddingright editfielda" href="'.$url.'action=edit&token='.newToken().'">'.img_edit().'</a>';
2672 }
2673 // Delete link
2674 if ($iserasable) {
2675 if ($user->admin) {
2676 print '<a class="reposition marginleftonly paddingleft marginrightonly paddingright" href="'.$url.'action=delete&token='.newToken().'">'.img_delete().'</a>';
2677 }
2678 }
2679 print '</td>';
2680 }
2681
2682 print "</tr>\n";
2683 }
2684 $i++;
2685 }
2686 } else {
2687 print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
2688 }
2689
2690 print '</table>';
2691 print '</div>';
2692 } else {
2693 dol_print_error($db);
2694 }
2695
2696 print '</form>';
2697} else {
2698 /*
2699 * Show list of dictionary to show
2700 */
2701 print load_fiche_titre($title, $linkback, $titlepicto);
2702
2703 print '<span class="opacitymedium">'.$langs->trans("DictionaryDesc");
2704 print " ".$langs->trans("OnlyActiveElementsAreShown")."<br>\n";
2705 print '</span><br>';
2706 print "<br>\n";
2707
2708 $lastlineisempty = false;
2709
2710 print '<div class="div-table-responsive-no-min">';
2711 print '<table class="noborder centpercent">';
2712 print '<tr class="liste_titre">';
2713 print '<td>'.$langs->trans("Dictionary").'</td>';
2714 print '<td></td>';
2715 print '<td class="hideonsmartphone"></td>';
2716 print '</tr>';
2717
2718 $showemptyline = '';
2719 foreach ($taborder as $i) {
2720 if (isset($tabname[$i]) && empty($tabcond[$i])) {
2721 continue;
2722 }
2723
2724 if ($i) {
2725 if ($showemptyline) {
2726 print '<tr class="oddeven"><td></td><td></td><td class="hideonsmartphone"></td></tr>';
2727 $showemptyline = 0;
2728 }
2729
2730
2731 $value = $tabname[$i];
2732 print '<tr class="oddeven"><td class="minwidth200">';
2733 if (!empty($tabcond[$i])) {
2734 $tabnamenoprefix = preg_replace('/'.MAIN_DB_PREFIX.'/', '', $tabname[$i]);
2735 print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$i;
2736 if ($i == DICT_CHARGESOCIALES) {
2737 print '&search_country_id='.$mysoc->country_id;
2738 }
2739 print '">';
2740 if (!empty($tabcomplete[$tabnamenoprefix]['picto'])) {
2741 print img_picto('', $tabcomplete[$tabnamenoprefix]['picto'], 'class="pictofixedwidth paddingrightonly"');
2742 }
2743 print $langs->trans($tablib[$i]);
2744 print '</a>';
2745 } else {
2746 print $langs->trans($tablib[$i]);
2747 }
2748 print '</td>';
2749 print '<td>';
2750 print '<a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?id='.$i.'">';
2751 print img_picto('Edit', 'edit', '');
2752 print '</a>';
2753 print '</td>';
2754 print '<td class="right hideonsmartphone">';
2755 print $form->textwithpicto('', $langs->trans("Table").': '.MAIN_DB_PREFIX.$tabname[$i]);
2756 print '</td>';
2757 print '</tr>';
2758 $lastlineisempty = false;
2759 } else {
2760 if (!$lastlineisempty) {
2761 $showemptyline = 1;
2762 $lastlineisempty = true;
2763 }
2764 }
2765 }
2766 print '</table>';
2767 print '</div>';
2768}
2769
2770print '<br>';
2771if (GETPOST('id') && GETPOST('id') == DICT_SOCIALNETWORKS) {
2772 print dol_get_fiche_end();
2773}
2774// End of page
2775llxFooter();
2776$db->close();
2777
2778
2787function dictFieldLabel($value, $tabname = '', $tablib = '')
2788{
2789 global $langs;
2790
2791 $valuetoshow = ucfirst($value); // By default
2792 $valuetoshow = $langs->trans($valuetoshow); // try to translate
2793
2794 // Special cases
2795 if ($value == 'source') {
2796 $valuetoshow = $langs->trans("Contact");
2797 }
2798 if ($value == 'price') {
2799 $valuetoshow = $langs->trans("PriceUHT");
2800 }
2801 if ($value == 'taux') {
2802 if ($tabname != "c_revenuestamp") {
2803 $valuetoshow = $langs->trans("Rate");
2804 } else {
2805 $valuetoshow = $langs->trans("Amount");
2806 }
2807 }
2808 if ($value == 'type_vat') {
2809 $valuetoshow = $langs->trans("VATType");
2810 }
2811 if ($value == 'localtax1_type') {
2812 $valuetoshow = $langs->trans("UseLocalTax")." 2";
2813 }
2814 if ($value == 'localtax1') {
2815 $valuetoshow = $langs->trans("RateOfTaxN", '2');
2816 }
2817 if ($value == 'localtax2_type') {
2818 $valuetoshow = $langs->trans("UseLocalTax")." 3";
2819 }
2820 if ($value == 'localtax2') {
2821 $valuetoshow = $langs->trans("RateOfTaxN", '3');
2822 }
2823 if ($value == 'organization') {
2824 $valuetoshow = $langs->trans("Organization");
2825 }
2826 if ($value == 'lang') {
2827 $valuetoshow = $langs->trans("Language");
2828 }
2829 if ($value == 'type') {
2830 $valuetoshow = $langs->trans("Type");
2831 }
2832 if ($value == 'code') {
2833 $valuetoshow = $langs->trans("Code");
2834 }
2835 if (in_array($value, array('pos', 'position'))) {
2836 $valuetoshow = $langs->trans("Position");
2837 }
2838 if ($value == 'libelle' || $value == 'label') {
2839 $valuetoshow = $langs->trans("Label");
2840 }
2841 if ($value == 'libelle_facture') {
2842 $valuetoshow = $langs->trans("LabelOnDocuments");
2843 }
2844 if ($value == 'deposit_percent') {
2845 $valuetoshow = $langs->trans('DepositPercent');
2846 }
2847 if ($value == 'country') {
2848 $valuetoshow = $langs->trans("Country");
2849 }
2850 if ($value == 'phone_code') {
2851 $valuetoshow = $langs->trans("PhoneCode");
2852 }
2853 if ($value == 'trunk_prefix') {
2854 $valuetoshow = $langs->trans("TrunkPrefix");
2855 }
2856 if ($value == 'department_buyer') {
2857 $valuetoshow = $langs->trans('DepartmentBuyer');
2858 }
2859 if ($value == 'recuperableonly') {
2860 $valuetoshow = $langs->trans("NPR");
2861 }
2862 if ($value == 'einvoice_vatex') {
2863 $valuetoshow = $langs->trans("VATExemptionCode");
2864 }
2865 if ($value == 'nbjour') {
2866 $valuetoshow = $langs->trans("NbOfDays");
2867 }
2868 if ($value == 'type_cdr') {
2869 $valuetoshow = $langs->trans("AtEndOfMonth");
2870 }
2871 if ($value == 'decalage') {
2872 $valuetoshow = $langs->trans("Offset");
2873 }
2874 if ($value == 'width' || $value == 'nx') {
2875 $valuetoshow = $langs->trans("Width");
2876 }
2877 if ($value == 'height' || $value == 'ny') {
2878 $valuetoshow = $langs->trans("Height");
2879 }
2880 if ($value == 'unit' || $value == 'metric') {
2881 $valuetoshow = $langs->trans("MeasuringUnit");
2882 }
2883 if ($value == 'accountancy_code') {
2884 $valuetoshow = $langs->trans("AccountancyCode");
2885 }
2886 if ($value == 'accountancy_code_sell') {
2887 $valuetoshow = $langs->trans("AccountancyCodeSell");
2888 }
2889 if ($value == 'accountancy_code_buy') {
2890 $valuetoshow = $langs->trans("AccountancyCodeBuy");
2891 }
2892 if ($value == 'fk_pcg_version') {
2893 $valuetoshow = $langs->trans("Pcg_version");
2894 }
2895 if ($value == 'account_parent') {
2896 $valuetoshow = $langs->trans("Accountsparent");
2897 }
2898 if ($value == 'pcg_type') {
2899 $valuetoshow = $langs->trans("Pcg_type");
2900 }
2901 if ($value == 'pcg_subtype') {
2902 $valuetoshow = $langs->trans("Pcg_subtype");
2903 }
2904 if ($value == 'sortorder') {
2905 $valuetoshow = $langs->trans("SortOrder");
2906 }
2907 if ($value == 'short_label') {
2908 $valuetoshow = $langs->trans("ShortLabel");
2909 }
2910 if ($value == 'fk_parent') {
2911 $valuetoshow = $langs->trans("ParentID");
2912 }
2913 if ($value == 'range_account') {
2914 $valuetoshow = $langs->trans("Range");
2915 }
2916 if ($value == 'sens') {
2917 $valuetoshow = $langs->trans("Sens");
2918 }
2919 if ($value == 'category_type') {
2920 $valuetoshow = $langs->trans("Calculated");
2921 }
2922 if ($value == 'formula') {
2923 $valuetoshow = $langs->trans("Formula");
2924 }
2925 if ($value == 'paper_size') {
2926 $valuetoshow = $langs->trans("PaperSize");
2927 }
2928 if ($value == 'orientation') {
2929 $valuetoshow = $langs->trans("Orientation");
2930 }
2931 if ($value == 'leftmargin') {
2932 $valuetoshow = $langs->trans("LeftMargin");
2933 }
2934 if ($value == 'topmargin') {
2935 $valuetoshow = $langs->trans("TopMargin");
2936 }
2937 if ($value == 'spacex') {
2938 $valuetoshow = $langs->trans("SpaceX");
2939 }
2940 if ($value == 'spacey') {
2941 $valuetoshow = $langs->trans("SpaceY");
2942 }
2943 if ($value == 'font_size') {
2944 $valuetoshow = $langs->trans("FontSize");
2945 }
2946 if ($value == 'custom_x') {
2947 $valuetoshow = $langs->trans("CustomX");
2948 }
2949 if ($value == 'custom_y') {
2950 $valuetoshow = $langs->trans("CustomY");
2951 }
2952 if ($value == 'percent') {
2953 $valuetoshow = $langs->trans("Percentage");
2954 }
2955 if ($value == 'affect') {
2956 $valuetoshow = $langs->trans("WithCounter");
2957 }
2958 if ($value == 'delay') {
2959 $valuetoshow = $langs->trans("NoticePeriod");
2960 }
2961 if ($value == 'newbymonth') {
2962 $valuetoshow = $langs->trans("NewByMonth");
2963 }
2964 if ($value == 'fk_tva') {
2965 $valuetoshow = $langs->trans("VAT");
2966 }
2967 if ($value == 'range_ik') {
2968 $valuetoshow = $langs->trans("RangeIk");
2969 }
2970 if ($value == 'fk_c_exp_tax_cat') {
2971 $valuetoshow = $langs->trans("CarCategory");
2972 }
2973 if ($value == 'revenuestamp_type') {
2974 $valuetoshow = $langs->trans('TypeOfRevenueStamp');
2975 }
2976 if ($value == 'use_default') {
2977 $valuetoshow = $langs->trans('Default');
2978 }
2979 if ($value == 'unit_type') {
2980 $valuetoshow = $langs->trans('TypeOfUnit');
2981 }
2982 if ($value == 'public' && $tablib == 'TicketDictCategory') {
2983 $valuetoshow = $langs->trans('TicketGroupIsPublic');
2984 }
2985 if ($value == 'block_if_negative') {
2986 $valuetoshow = $langs->trans('BlockHolidayIfNegative');
2987 }
2988 if ($value == 'type_duration') {
2989 $valuetoshow = $langs->trans('Unit');
2990 }
2991
2992 return $valuetoshow;
2993}
2994
2995
3005function dictFieldList($fieldlist, $obj = null, $tabname = '', $context = '')
3006{
3007 global $langs, $db, $mysoc;
3008 global $form, $formother;
3009 global $region_id;
3010 global $elementList, $sourceList, $localtax_typeList, $type_vatList;
3011
3012 $formadmin = new FormAdmin($db);
3013 $formcompany = new FormCompany($db);
3014 $formaccounting = new FormAccounting($db);
3015
3016 $withentity = '';
3017
3018 foreach ($fieldlist as $field => $value) {
3019 if ($value == 'entity' && isset($obj->$value)) {
3020 $withentity = $obj->$value;
3021 continue;
3022 }
3023
3024 if (in_array($value, array('code', 'libelle', 'type')) && $tabname == "c_actioncomm" && isset($obj->$value) && in_array($obj->type, array('system', 'systemauto'))) {
3025 // Special case for c_actioncomm (field that should not be modified)
3026 $hidden = (!empty($obj->{$value}) ? $obj->{$value} : '');
3027 print '<td>';
3028 print '<input type="hidden" name="'. $value .'" value="'.$hidden.'">';
3029 print $langs->trans($hidden);
3030 print '</td>';
3031 } elseif ($value == 'country') {
3032 if (in_array('region_id', $fieldlist)) {
3033 print '<td>';
3034 print '</td>';
3035 continue;
3036 } // For state page, we do not show the country input (we link to region, not country)
3037 print '<td>';
3038
3039 $selected = (!empty($obj->country_code) ? $obj->country_code : (!empty($obj->country) ? $obj->country : ''));
3040 if (!GETPOSTISSET('code')) {
3041 $selected = GETPOST('countryidforinsert');
3042 }
3043 print $form->select_country($selected, $value, '', 28, 'minwidth100 maxwidth150 maxwidthonsmartphone');
3044 print '</td>';
3045 } elseif ($value == 'country_id') {
3046 if (!in_array('country', $fieldlist)) { // If there is already a field country, we don't show country_id (avoid duplicate)
3047 $country_id = (!empty($obj->{$value}) ? $obj->{$value} : 0);
3048 print '<td class="tdoverflowmax100">';
3049 print '<input type="hidden" name="'. $value .'" value="'.$country_id.'">';
3050 print '</td>';
3051 }
3052 } elseif ($value == 'region') {
3053 print '<td>';
3054 $formcompany->select_region($region_id, 'region');
3055 print '</td>';
3056 } elseif ($value == 'region_id') {
3057 $region_id = (!empty($obj->{$value}) ? $obj->{$value} : 0);
3058 print '<td>';
3059 print '<input type="hidden" name="'. $value .'" value="'.$region_id.'">';
3060 print '</td>';
3061 } elseif ($value == 'department_buyer') {
3062 if ($context == 'edit') {
3063 print '<td class="nowraponall">';
3064 // show department buyer list
3065 $country_code = (!empty($obj->country_code) ? $obj->country_code : '');
3066 $department_buyer_id = (!empty($obj->department_buyer_id) ? (int) $obj->department_buyer_id : 0);
3067 if ($country_code != '') {
3068 print $formcompany->select_state($department_buyer_id, $country_code, 'department_buyer_id', 'minwidth100 maxwidth150 maxwidthonsmartphone');
3069 }
3070 print '</td>';
3071 }
3072 } elseif ($value == 'department_buyer_id') {
3073 if (!in_array('department_buyer', $fieldlist)) { // If there is already a field department buyer, we don't show department buyer id (avoid duplicate)
3074 $department_buyer_id = (!empty($obj->{$value}) ? $obj->{$value} : 0);
3075 print '<td class="tdoverflowmax100">';
3076 print '<input type="hidden" name="'.$value.'" value="'.$department_buyer_id.'">';
3077 print '</td>';
3078 }
3079 } elseif ($value == 'lang') {
3080 print '<td>';
3081 print $formadmin->select_language(getDolGlobalString('MAIN_LANG_DEFAULT'), 'lang');
3082 print '</td>';
3083 } elseif (in_array($value, array('element', 'source'))) { // Example: the type and source of the element (for contact types)
3084 $tmparray = array();
3085 if ($value == 'element') {
3086 $tmparray = $elementList;
3087 } else {
3088 $tmparray = $sourceList;
3089 }
3090 print '<td>';
3091 print $form->selectarray($value, $tmparray, (!empty($obj->{$value}) ? $obj->{$value} : ''), 0, 0, 0, '', 0, 0, 0, '', 'maxwidth250');
3092 print '</td>';
3093 } elseif (in_array($value, array('public', 'use_default'))) {
3094 // Fields 0/1 with a combo select Yes/No
3095 print '<td class="center">';
3096 // @phan-suppress-next-line PhanPluginSuspiciousParamPosition
3097 print $form->selectyesno($value, (!empty($obj->{$value}) ? $obj->{$value} : ''), 1);
3098 print '</td>';
3099 } elseif ($value == 'private') {
3100 // Fields 'no'/'yes' with a combo select Yes/No
3101 print '<td>';
3102 print $form->selectyesno("private", (!empty($obj->{$value}) ? $obj->{$value} : ''));
3103 print '</td>';
3104 } elseif ($value == 'type' && $tabname == "c_actioncomm") {
3105 $type = (!empty($obj->type) ? $obj->type : 'user'); // Check if type is different of 'user' (external module)
3106 print '<td>';
3107 print $type.'<input type="hidden" name="type" value="'.$type.'">';
3108 print '</td>';
3109 } elseif ($value == 'type' && $tabname == 'c_paiement') {
3110 print '<td>';
3111 $select_list = array(0 => $langs->trans('PaymentTypeCustomer'), 1 => $langs->trans('PaymentTypeSupplier'), 2 => $langs->trans('PaymentTypeBoth'));
3112 // Use isset(), not !empty(), because 0 (Customer) is a valid value that empty() would treat as unset
3113 print $form->selectarray($value, $select_list, (isset($obj->{$value}) && $obj->{$value} !== '' ? $obj->{$value} : '2'));
3114 print '</td>';
3115 } elseif ($value == 'recuperableonly' || $value == 'type_cdr' || $value == 'deductible' || $value == 'category_type') {
3116 if ($value == 'type_cdr') {
3117 print '<td class="center">';
3118 } else {
3119 print '<td>';
3120 }
3121 if ($value == 'type_cdr') {
3122 print $form->selectarray($value, array(0 => $langs->trans('None'), 1 => $langs->trans('AtEndOfMonth'), 2 => $langs->trans('CurrentNext')), (!empty($obj->{$value}) ? $obj->{$value} : ''));
3123 } else {
3124 // @phan-suppress-next-line PhanPluginSuspiciousParamPosition
3125 print $form->selectyesno($value, (!empty($obj->{$value}) ? $obj->{$value} : ''), 1);
3126 }
3127 print '</td>';
3128 } elseif (in_array($value, array('nbjour', 'decalage', 'taux', 'localtax1', 'localtax2'))) {
3129 $class = "right";
3130 if (in_array($value, array('taux', 'localtax1', 'localtax2'))) {
3131 $class = "center"; // Fields aligned on right
3132 }
3133 print '<td class="'.$class.'">';
3134 print '<input type="text" class="flat" value="'.(isset($obj->{$value}) ? $obj->{$value} : '').'" size="3" name="'. $value .'">';
3135 print '</td>';
3136 } elseif (in_array($value, array('libelle_facture', 'content'))) {
3137 print '<td>';
3138 $transfound = 0;
3139 $transkey = '';
3140 // Special case for labels
3141 if ($tabname == 'c_payment_term') {
3142 $langs->load("bills");
3143 if (isset($obj->code) && !empty($obj->code)) {
3144 $transkey = "PaymentCondition" . strtoupper($obj->code);
3145 if ($langs->trans($transkey) != $transkey) {
3146 $transfound = 1;
3147 print $form->textwithpicto($langs->trans($transkey), $langs->trans("GoIntoTranslationMenuToChangeThis"));
3148 }
3149 }
3150 }
3151 if (!$transfound) {
3152 print '<textarea cols="30" rows="'.ROWS_2.'" class="flat" name="'. $value .'">'.(empty($obj->{$value}) ? '' : $obj->{$value}).'</textarea>';
3153 } else {
3154 print '<input type="hidden" name="'. $value .'" value="'.$transkey.'">';
3155 }
3156 print '</td>';
3157 } elseif ($value == 'price' || preg_match('/^amount/i', (string) $value)) {
3158 print '<td><input type="text" class="flat minwidth75" value="'.price((!empty($obj->{$value}) ? $obj->{$value} : '')).'" name="'. $value .'"></td>';
3159 } elseif ($value == 'code' && isset($obj->{$value})) {
3160 print '<td>';
3161 if ($tabname == 'c_paiement' && in_array($obj->{$value}, array('LIQ', 'CB', 'CHQ', 'VIR'))) {
3162 // Case of code that should not be modified
3163 print '<input type="hidden" class="flat minwidth75 maxwidth100" value="'.(empty($obj->{$value}) ? '' : $obj->{$value}).'" name="'. $value .'">';
3164 print $obj->{$value};
3165 } else {
3166 print '<input type="text" class="flat minwidth75 maxwidth100" value="'.(empty($obj->{$value}) ? '' : $obj->{$value}).'" name="'. $value .'">';
3167 }
3168 print '</td>';
3169 } elseif ($value == 'unit') {
3170 print '<td>';
3171 $units = array(
3172 'mm' => $langs->trans('SizeUnitmm'),
3173 'cm' => $langs->trans('SizeUnitcm'),
3174 'point' => $langs->trans('SizeUnitpoint'),
3175 'inch' => $langs->trans('SizeUnitinch')
3176 );
3177 print $form->selectarray('unit', $units, (empty($obj->{$value}) ? '' : $obj->{$value}), 0, 0, 0);
3178 print '</td>';
3179 } elseif ($value == 'type_vat') {
3180 // VAT type 0: all, 1: sell, 2: purchase
3181 print '<td class="center">';
3182 print $form->selectarray($value, $type_vatList, (empty($obj->{$value}) ? '0' : $obj->{$value}));
3183 print '</td>';
3184 } elseif ($value == 'localtax1_type' || $value == 'localtax2_type') {
3185 // Le type de taxe locale
3186 print '<td class="center">';
3187 print $form->selectarray($value, $localtax_typeList, (empty($obj->{$value}) ? '' : $obj->{$value}));
3188 print '</td>';
3189 } elseif ($value == 'accountancy_code' || $value == 'accountancy_code_sell' || $value == 'accountancy_code_buy') {
3190 print '<td>';
3191 if (isModEnabled('accounting')) {
3192 $fieldname = $value;
3193 $accountancy_account = (empty($obj->$fieldname) ? 0 : $obj->$fieldname);
3194 print $formaccounting->select_account($accountancy_account, '.'. $value, 1, array(), 1, 1, 'maxwidth125 maxwidthonsmartphone');
3195 } else {
3196 $fieldname = $value;
3197 print '<input type="text" class="flat minwidth100" value="'.(isset($obj->$fieldname) ? $obj->$fieldname : '').'" name="'. $value .'">';
3198 }
3199 print '</td>';
3200 } elseif ($value == 'fk_tva') {
3201 print '<td>';
3202 print $form->load_tva('fk_tva', $obj->taux, $mysoc, new Societe($db), 0, 0, '', false, -1);
3203 print '</td>';
3204 } elseif ($value == 'fk_c_exp_tax_cat') {
3205 print '<td>';
3206 print $form->selectExpenseCategories($obj->fk_c_exp_tax_cat);
3207 print '</td>';
3208 } elseif ($value == 'fk_range') {
3209 print '<td>';
3210 print $form->selectExpenseRanges($obj->fk_range);
3211 print '</td>';
3212 } elseif ($value == 'block_if_negative') {
3213 print '<td>';
3214 print $form->selectyesno("block_if_negative", (empty($obj->block_if_negative) ? '' : $obj->block_if_negative), 1);
3215 print '</td>';
3216 } elseif ($value == 'type_duration') {
3217 print '<td>';
3218 print $form->selectTypeDuration('', (empty($obj->type_duration) ? '' : $obj->type_duration), ['s', 'i', 'h']);
3219 print '</td>';
3220 } elseif ($value == 'color') {
3221 print '<td>';
3222 print $formother->selectColor((empty($obj->{$value}) ? '' : $obj->{$value}), 'color');
3223 print '</td>';
3224 } else {
3225 $fieldValue = isset($obj->{$value}) ? $obj->{$value} : '';
3226 $classtd = '';
3227 $class = '';
3228
3229 if ($value == 'sortorder') {
3230 $fieldlist[$field] = 'position';
3231 }
3232
3233 if ($fieldlist[$field] == 'code') {
3234 $class = 'maxwidth100';
3235 }
3236 if (in_array($fieldlist[$field], array('deposit_percent'))) {
3237 $classtd = 'right';
3238 $class = 'maxwidth50 right';
3239 }
3240 if (in_array($fieldlist[$field], array('pos', 'position'))) {
3241 $classtd = 'right';
3242 $class = 'maxwidth50 right';
3243 }
3244 if (in_array($fieldlist[$field], array('dayrule', 'day', 'month', 'year', 'use_default', 'affect', 'delay', 'public', 'sortorder', 'sens', 'category_type', 'fk_parent'))) {
3245 $class = 'maxwidth50 center';
3246 }
3247 if (in_array($fieldlist[$field], array('use_default', 'public', 'fk_parent'))) {
3248 $classtd = 'center';
3249 }
3250 if (in_array($fieldlist[$field], array('libelle', 'label', 'tracking'))) {
3251 $class = 'quatrevingtpercent';
3252 }
3253 // Fields that must be suggested as '0' instead of ''
3254 if ($fieldlist[$field] == 'fk_parent') {
3255 if (empty($fieldValue)) {
3256 $fieldValue = '0';
3257 }
3258 }
3259
3260 // Labels Length
3261 $maxlength = '';
3262 if (in_array($fieldlist[$field], array('libelle', 'label'))) {
3263 switch ($tabname) {
3264 case 'c_ecotaxe':
3265 case 'c_email_senderprofile':
3266 case 'c_forme_juridique':
3267 case 'c_holiday_types':
3268 case 'c_payment_term':
3269 case 'c_transport_mode':
3270 $maxlength = ' maxlength="255"';
3271 break;
3272 case 'c_email_templates':
3273 $maxlength = ' maxlength="180"';
3274 break;
3275 case 'c_socialnetworks':
3276 $maxlength = ' maxlength="150"';
3277 break;
3278 default:
3279 $maxlength = ' maxlength="128"';
3280 }
3281 }
3282
3283 print '<td class="'.$classtd.'">';
3284 $transfound = 0;
3285 $transkey = '';
3286 if (in_array($fieldlist[$field], array('label', 'libelle'))) { // For label
3287 // Special case for labels
3288 if ($tabname == 'c_civility' && !empty($obj->code)) {
3289 $transkey = "Civility".strtoupper($obj->code);
3290 }
3291 if ($tabname == 'c_payment_term' && !empty($obj->code)) {
3292 $langs->load("bills");
3293 $transkey = "PaymentConditionShort".strtoupper($obj->code);
3294 }
3295 if ($transkey && $langs->trans($transkey) != $transkey) {
3296 $transfound = 1;
3297 print $form->textwithpicto($langs->trans($transkey), $langs->trans("GoIntoTranslationMenuToChangeThis"));
3298 }
3299 }
3300 if (!$transfound) {
3301 print '<input type="text" class="flat'.($class ? ' '.$class : '').'"'.($maxlength ? ' '.$maxlength : '').' value="'.dol_escape_htmltag($fieldValue).'" name="'.$fieldlist[$field].'">';
3302 } else {
3303 print '<input type="hidden" name="'.$fieldlist[$field].'" value="'.$transkey.'">';
3304 }
3305 print '</td>';
3306 }
3307 }
3308
3309 return $withentity;
3310}
$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:280
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:91
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:73
Class to manage 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...)
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:2787
dictFieldList($fieldlist, $obj=null, $tabname='', $context='')
Show fields in insert/edit mode.
Definition dict.php:3005
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
price2num($amount, $rounding='', $option=0)
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:540
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:738
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:181
$context
@method int call_trigger(string $triggerName, ?User $user)
Definition logout.php:42
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.