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