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