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