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