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