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