dolibarr  13.0.2
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-2016 Juanjo Menent <jmenent@2byte.es>
7  * Copyright (C) 2011-2019 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-2019 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 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"));
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)) $allowed = 1; // Tax page allowed to manager of chart account
58 if ($id == 10 && !empty($user->rights->accounting->chartofaccount)) $allowed = 1; // Vat page allowed to manager of chart account
59 if ($id == 17 && !empty($user->rights->accounting->chartofaccount)) $allowed = 1; // Dictionary with type of expense report and accounting account allowed to manager of chart account
60 if (!$allowed) accessforbidden();
61 
62 $acts = array(); $actl = array();
63 $acts[0] = "activate";
64 $acts[1] = "disable";
65 $actl[0] = img_picto($langs->trans("Disabled"), 'switch_off');
66 $actl[1] = img_picto($langs->trans("Activated"), 'switch_on');
67 
68 $listoffset = GETPOST('listoffset');
69 $listlimit = GETPOST('listlimit') > 0 ?GETPOST('listlimit') : 1000; // To avoid too long dictionaries
70 $active = 1;
71 
72 $sortfield = GETPOST("sortfield", 'alpha');
73 $sortorder = GETPOST("sortorder", 'alpha');
74 $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
75 if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
76 $offset = $listlimit * $page;
77 $pageprev = $page - 1;
78 $pagenext = $page + 1;
79 
80 $search_country_id = GETPOST('search_country_id', 'int');
81 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.
82 {
83  $search_country_id = $mysoc->country_id;
84 }
85 $search_code = GETPOST('search_code', 'alpha');
86 
87 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
88 $hookmanager->initHooks(array('admin'));
89 
90 // This page is a generic page to edit dictionaries
91 // Put here declaration of dictionaries properties
92 
93 // Sort order to show dictionary (0 is space). All other dictionaries (added by modules) will be at end of this.
94 $taborder = array(9, 0, 4, 3, 2, 0, 1, 8, 19, 16, 39, 27, 40, 38, 0, 5, 11, 0, 32, 33, 34, 0, 6, 0, 29, 0, 7, 24, 28, 17, 35, 36, 0, 10, 23, 12, 13, 0, 14, 0, 22, 20, 18, 21, 41, 0, 15, 30, 0, 37, 42, 0, 25, 0);
95 
96 // Name of SQL tables of dictionaries
97 $tabname = array();
98 $tabname[1] = MAIN_DB_PREFIX."c_forme_juridique";
99 $tabname[2] = MAIN_DB_PREFIX."c_departements";
100 $tabname[3] = MAIN_DB_PREFIX."c_regions";
101 $tabname[4] = MAIN_DB_PREFIX."c_country";
102 $tabname[5] = MAIN_DB_PREFIX."c_civility";
103 $tabname[6] = MAIN_DB_PREFIX."c_actioncomm";
104 $tabname[7] = MAIN_DB_PREFIX."c_chargesociales";
105 $tabname[8] = MAIN_DB_PREFIX."c_typent";
106 $tabname[9] = MAIN_DB_PREFIX."c_currencies";
107 $tabname[10] = MAIN_DB_PREFIX."c_tva";
108 $tabname[11] = MAIN_DB_PREFIX."c_type_contact";
109 $tabname[12] = MAIN_DB_PREFIX."c_payment_term";
110 $tabname[13] = MAIN_DB_PREFIX."c_paiement";
111 $tabname[14] = MAIN_DB_PREFIX."c_ecotaxe";
112 $tabname[15] = MAIN_DB_PREFIX."c_paper_format";
113 $tabname[16] = MAIN_DB_PREFIX."c_prospectlevel";
114 $tabname[17] = MAIN_DB_PREFIX."c_type_fees";
115 $tabname[18] = MAIN_DB_PREFIX."c_shipment_mode";
116 $tabname[19] = MAIN_DB_PREFIX."c_effectif";
117 $tabname[20] = MAIN_DB_PREFIX."c_input_method";
118 $tabname[21] = MAIN_DB_PREFIX."c_availability";
119 $tabname[22] = MAIN_DB_PREFIX."c_input_reason";
120 $tabname[23] = MAIN_DB_PREFIX."c_revenuestamp";
121 $tabname[24] = MAIN_DB_PREFIX."c_type_resource";
122 $tabname[25] = MAIN_DB_PREFIX."c_type_container";
123 //$tabname[26]= MAIN_DB_PREFIX."c_units";
124 $tabname[27] = MAIN_DB_PREFIX."c_stcomm";
125 $tabname[28] = MAIN_DB_PREFIX."c_holiday_types";
126 $tabname[29] = MAIN_DB_PREFIX."c_lead_status";
127 $tabname[30] = MAIN_DB_PREFIX."c_format_cards";
128 //$tabname[31]= MAIN_DB_PREFIX."accounting_system";
129 $tabname[32] = MAIN_DB_PREFIX."c_hrm_public_holiday";
130 $tabname[33] = MAIN_DB_PREFIX."c_hrm_department";
131 $tabname[34] = MAIN_DB_PREFIX."c_hrm_function";
132 $tabname[35] = MAIN_DB_PREFIX."c_exp_tax_cat";
133 $tabname[36] = MAIN_DB_PREFIX."c_exp_tax_range";
134 $tabname[37] = MAIN_DB_PREFIX."c_units";
135 $tabname[38] = MAIN_DB_PREFIX."c_socialnetworks";
136 $tabname[39] = MAIN_DB_PREFIX."c_prospectcontactlevel";
137 $tabname[40] = MAIN_DB_PREFIX."c_stcommcontact";
138 $tabname[41] = MAIN_DB_PREFIX."c_transport_mode";
139 $tabname[42] = MAIN_DB_PREFIX."c_product_nature";
140 
141 // Dictionary labels
142 $tablib = array();
143 $tablib[1] = "DictionaryCompanyJuridicalType";
144 $tablib[2] = "DictionaryCanton";
145 $tablib[3] = "DictionaryRegion";
146 $tablib[4] = "DictionaryCountry";
147 $tablib[5] = "DictionaryCivility";
148 $tablib[6] = "DictionaryActions";
149 $tablib[7] = "DictionarySocialContributions";
150 $tablib[8] = "DictionaryCompanyType";
151 $tablib[9] = "DictionaryCurrency";
152 $tablib[10] = "DictionaryVAT";
153 $tablib[11] = "DictionaryTypeContact";
154 $tablib[12] = "DictionaryPaymentConditions";
155 $tablib[13] = "DictionaryPaymentModes";
156 $tablib[14] = "DictionaryEcotaxe";
157 $tablib[15] = "DictionaryPaperFormat";
158 $tablib[16] = "DictionaryProspectLevel";
159 $tablib[17] = "DictionaryFees";
160 $tablib[18] = "DictionarySendingMethods";
161 $tablib[19] = "DictionaryStaff";
162 $tablib[20] = "DictionaryOrderMethods";
163 $tablib[21] = "DictionaryAvailability";
164 $tablib[22] = "DictionarySource";
165 $tablib[23] = "DictionaryRevenueStamp";
166 $tablib[24] = "DictionaryResourceType";
167 $tablib[25] = "DictionaryTypeOfContainer";
168 //$tablib[26]= "DictionaryUnits";
169 $tablib[27] = "DictionaryProspectStatus";
170 $tablib[28] = "DictionaryHolidayTypes";
171 $tablib[29] = "DictionaryOpportunityStatus";
172 $tablib[30] = "DictionaryFormatCards";
173 //$tablib[31]= "DictionaryAccountancysystem";
174 $tablib[32] = "DictionaryPublicHolidays";
175 $tablib[33] = "DictionaryDepartment";
176 $tablib[34] = "DictionaryFunction";
177 $tablib[35] = "DictionaryExpenseTaxCat";
178 $tablib[36] = "DictionaryExpenseTaxRange";
179 $tablib[37] = "DictionaryMeasuringUnits";
180 $tablib[38] = "DictionarySocialNetworks";
181 $tablib[39] = "DictionaryProspectContactLevel";
182 $tablib[40] = "DictionaryProspectContactStatus";
183 $tablib[41] = "DictionaryTransportMode";
184 $tablib[42] = "DictionaryProductNature";
185 
186 // Requests to extract data
187 $tabsql = array();
188 $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";
189 $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";
190 $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";
191 $tabsql[4] = "SELECT c.rowid as rowid, c.code, c.label, c.active, c.favorite FROM ".MAIN_DB_PREFIX."c_country AS c";
192 $tabsql[5] = "SELECT c.rowid as rowid, c.code as code, c.label, c.active FROM ".MAIN_DB_PREFIX."c_civility AS c";
193 $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";
194 $tabsql[7] = "SELECT a.id as rowid, a.code as code, a.libelle AS libelle, a.accountancy_code as accountancy_code, a.deductible, 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";
195 $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";
196 $tabsql[9] = "SELECT c.code_iso as code, c.label, c.unicode, c.active FROM ".MAIN_DB_PREFIX."c_currencies AS c";
197 $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";
198 $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";
199 $tabsql[12] = "SELECT c.rowid as rowid, c.code, c.libelle, c.libelle_facture, 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]);
200 $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]);
201 $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";
202 $tabsql[15] = "SELECT rowid as rowid, code, label as libelle, width, height, unit, active FROM ".MAIN_DB_PREFIX."c_paper_format";
203 $tabsql[16] = "SELECT code, label as libelle, sortorder, active FROM ".MAIN_DB_PREFIX."c_prospectlevel";
204 $tabsql[17] = "SELECT id as rowid, code, label, accountancy_code, active FROM ".MAIN_DB_PREFIX."c_type_fees";
205 $tabsql[18] = "SELECT rowid as rowid, code, libelle, tracking, active FROM ".MAIN_DB_PREFIX."c_shipment_mode";
206 $tabsql[19] = "SELECT id as rowid, code, libelle, active FROM ".MAIN_DB_PREFIX."c_effectif";
207 $tabsql[20] = "SELECT rowid as rowid, code, libelle, active FROM ".MAIN_DB_PREFIX."c_input_method";
208 $tabsql[21] = "SELECT c.rowid as rowid, code, label, active FROM ".MAIN_DB_PREFIX."c_availability AS c";
209 $tabsql[22] = "SELECT rowid as rowid, code, label, active FROM ".MAIN_DB_PREFIX."c_input_reason";
210 $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";
211 $tabsql[24] = "SELECT rowid as rowid, code, label, active FROM ".MAIN_DB_PREFIX."c_type_resource";
212 $tabsql[25] = "SELECT rowid as rowid, code, label, active, module FROM ".MAIN_DB_PREFIX."c_type_container as t WHERE t.entity IN (".getEntity('c_type_container').")";
213 //$tabsql[26]= "SELECT rowid as rowid, code, label, short_label, active FROM ".MAIN_DB_PREFIX."c_units";
214 $tabsql[27] = "SELECT id as rowid, code, libelle, picto, active FROM ".MAIN_DB_PREFIX."c_stcomm";
215 $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.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";
216 $tabsql[29] = "SELECT rowid as rowid, code, label, percent, position, active FROM ".MAIN_DB_PREFIX."c_lead_status";
217 $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";
218 //$tabsql[31]= "SELECT s.rowid as rowid, pcg_version, s.label, s.active FROM ".MAIN_DB_PREFIX."accounting_system as s";
219 $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";
220 $tabsql[33] = "SELECT rowid, pos, code, label, active FROM ".MAIN_DB_PREFIX."c_hrm_department";
221 $tabsql[34] = "SELECT rowid, pos, code, label, c_level, active FROM ".MAIN_DB_PREFIX."c_hrm_function";
222 $tabsql[35] = "SELECT c.rowid, c.label, c.active, c.entity FROM ".MAIN_DB_PREFIX."c_exp_tax_cat c";
223 $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";
224 $tabsql[37] = "SELECT r.rowid, r.code, r.label, r.short_label, r.unit_type, r.scale, r.active FROM ".MAIN_DB_PREFIX."c_units r";
225 $tabsql[38] = "SELECT rowid, entity, code, label, url, icon, active FROM ".MAIN_DB_PREFIX."c_socialnetworks";
226 $tabsql[39] = "SELECT code, label as libelle, sortorder, active FROM ".MAIN_DB_PREFIX."c_prospectcontactlevel";
227 $tabsql[40] = "SELECT id as rowid, code, libelle, picto, active FROM ".MAIN_DB_PREFIX."c_stcommcontact";
228 $tabsql[41] = "SELECT rowid as rowid, code, label, active FROM ".MAIN_DB_PREFIX."c_transport_mode";
229 $tabsql[42] = "SELECT rowid as rowid, code, label, active FROM ".MAIN_DB_PREFIX."c_product_nature";
230 
231 // Criteria to sort dictionaries
232 $tabsqlsort = array();
233 $tabsqlsort[1] = "country ASC, code ASC";
234 $tabsqlsort[2] = "country ASC, code ASC";
235 $tabsqlsort[3] = "country ASC, code ASC";
236 $tabsqlsort[4] = "code ASC";
237 $tabsqlsort[5] = "label ASC";
238 $tabsqlsort[6] = "a.type ASC, a.module ASC, a.position ASC, a.code ASC";
239 $tabsqlsort[7] = "c.label ASC, a.code ASC, a.libelle ASC";
240 $tabsqlsort[8] = "country DESC,".(!empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? ' t.position ASC,' : '')." libelle ASC";
241 $tabsqlsort[9] = "label ASC";
242 $tabsqlsort[10] = "country ASC, code ASC, taux ASC, recuperableonly ASC, localtax1 ASC, localtax2 ASC";
243 $tabsqlsort[11] = "t.element ASC, t.source ASC, t.position ASC, t.code ASC";
244 $tabsqlsort[12] = "sortorder ASC, code ASC";
245 $tabsqlsort[13] = "code ASC";
246 $tabsqlsort[14] = "country ASC, e.organization ASC, code ASC";
247 $tabsqlsort[15] = "rowid ASC";
248 $tabsqlsort[16] = "sortorder ASC";
249 $tabsqlsort[17] = "code ASC";
250 $tabsqlsort[18] = "code ASC, libelle ASC";
251 $tabsqlsort[19] = "id ASC";
252 $tabsqlsort[20] = "code ASC, libelle ASC";
253 $tabsqlsort[21] = "code ASC, label ASC";
254 $tabsqlsort[22] = "code ASC, label ASC";
255 $tabsqlsort[23] = "country ASC, taux ASC";
256 $tabsqlsort[24] = "code ASC, label ASC";
257 $tabsqlsort[25] = "t.module ASC, t.code ASC, t.label ASC";
258 //$tabsqlsort[26]="code ASC";
259 $tabsqlsort[27] = "code ASC";
260 $tabsqlsort[28] = "country ASC, code ASC";
261 $tabsqlsort[29] = "position ASC";
262 $tabsqlsort[30] = "code ASC";
263 //$tabsqlsort[31]="pcg_version ASC";
264 $tabsqlsort[32] = "country, year ASC, month ASC, day ASC";
265 $tabsqlsort[33] = "code ASC";
266 $tabsqlsort[34] = "code ASC";
267 $tabsqlsort[35] = "c.label ASC";
268 $tabsqlsort[36] = "r.fk_c_exp_tax_cat ASC, r.range_ik ASC";
269 $tabsqlsort[37] = "r.unit_type ASC, r.scale ASC, r.code ASC";
270 $tabsqlsort[38] = "rowid, code ASC";
271 $tabsqlsort[39] = "sortorder ASC";
272 $tabsqlsort[40] = "code ASC";
273 $tabsqlsort[41] = "code ASC";
274 $tabsqlsort[42] = "code ASC";
275 
276 // Field names in select result for dictionary display
277 $tabfield = array();
278 $tabfield[1] = "code,libelle,country";
279 $tabfield[2] = "code,libelle,region_id,region,country"; // "code,libelle,region,country_code-country"
280 $tabfield[3] = "code,libelle,country_id,country";
281 $tabfield[4] = "code,label";
282 $tabfield[5] = "code,label";
283 $tabfield[6] = "code,libelle,type,color,position";
284 $tabfield[7] = "code,libelle,country,accountancy_code,deductible";
285 $tabfield[8] = "code,libelle,country_id,country".(!empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? ',position' : '');
286 $tabfield[9] = "code,label,unicode";
287 $tabfield[10] = "country_id,country,code,taux,localtax1_type,localtax1,localtax2_type,localtax2,recuperableonly,accountancy_code_sell,accountancy_code_buy,note";
288 $tabfield[11] = "element,source,code,libelle,position";
289 $tabfield[12] = "code,libelle,libelle_facture,nbjour,type_cdr,decalage,sortorder,entity";
290 $tabfield[13] = "code,libelle,type,entity";
291 $tabfield[14] = "code,label,price,organization,country";
292 $tabfield[15] = "code,libelle,width,height,unit";
293 $tabfield[16] = "code,libelle,sortorder";
294 $tabfield[17] = "code,label,accountancy_code";
295 $tabfield[18] = "code,libelle,tracking";
296 $tabfield[19] = "code,libelle";
297 $tabfield[20] = "code,libelle";
298 $tabfield[21] = "code,label";
299 $tabfield[22] = "code,label";
300 $tabfield[23] = "country_id,country,taux,revenuestamp_type,accountancy_code_sell,accountancy_code_buy,note";
301 $tabfield[24] = "code,label";
302 $tabfield[25] = "code,label";
303 //$tabfield[26]= "code,label,short_label";
304 $tabfield[27] = "code,libelle,picto";
305 $tabfield[28] = "code,label,affect,delay,newbymonth,country_id,country";
306 $tabfield[29] = "code,label,percent,position";
307 $tabfield[30] = "code,name,paper_size,orientation,metric,leftmargin,topmargin,nx,ny,spacex,spacey,width,height,font_size,custom_x,custom_y";
308 //$tabfield[31]= "pcg_version,label";
309 $tabfield[32] = "code,dayrule,year,month,day,country_id,country";
310 $tabfield[33] = "code,label";
311 $tabfield[34] = "code,label";
312 $tabfield[35] = "label";
313 $tabfield[36] = "range_ik,fk_c_exp_tax_cat";
314 $tabfield[37] = "code,label,short_label,unit_type,scale";
315 $tabfield[38] = "code,label,url,icon,entity";
316 $tabfield[39] = "code,libelle,sortorder";
317 $tabfield[40] = "code,libelle,picto";
318 $tabfield[41] = "code,label";
319 $tabfield[42] = "code,label";
320 
321 // Edit field names for editing a record
322 $tabfieldvalue = array();
323 $tabfieldvalue[1] = "code,libelle,country";
324 $tabfieldvalue[2] = "code,libelle,region"; // "code,libelle,region"
325 $tabfieldvalue[3] = "code,libelle,country";
326 $tabfieldvalue[4] = "code,label";
327 $tabfieldvalue[5] = "code,label";
328 $tabfieldvalue[6] = "code,libelle,type,color,position";
329 $tabfieldvalue[7] = "code,libelle,country,accountancy_code,deductible";
330 $tabfieldvalue[8] = "code,libelle,country".(!empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? ',position' : '');
331 $tabfieldvalue[9] = "code,label,unicode";
332 $tabfieldvalue[10] = "country,code,taux,localtax1_type,localtax1,localtax2_type,localtax2,recuperableonly,accountancy_code_sell,accountancy_code_buy,note";
333 $tabfieldvalue[11] = "element,source,code,libelle,position";
334 $tabfieldvalue[12] = "code,libelle,libelle_facture,nbjour,type_cdr,decalage,sortorder";
335 $tabfieldvalue[13] = "code,libelle,type";
336 $tabfieldvalue[14] = "code,label,price,organization,country";
337 $tabfieldvalue[15] = "code,libelle,width,height,unit";
338 $tabfieldvalue[16] = "code,libelle,sortorder";
339 $tabfieldvalue[17] = "code,label,accountancy_code";
340 $tabfieldvalue[18] = "code,libelle,tracking";
341 $tabfieldvalue[19] = "code,libelle";
342 $tabfieldvalue[20] = "code,libelle";
343 $tabfieldvalue[21] = "code,label";
344 $tabfieldvalue[22] = "code,label";
345 $tabfieldvalue[23] = "country,taux,revenuestamp_type,accountancy_code_sell,accountancy_code_buy,note";
346 $tabfieldvalue[24] = "code,label";
347 $tabfieldvalue[25] = "code,label";
348 //$tabfieldvalue[26]= "code,label,short_label";
349 $tabfieldvalue[27] = "code,libelle,picto";
350 $tabfieldvalue[28] = "code,label,affect,delay,newbymonth,country";
351 $tabfieldvalue[29] = "code,label,percent,position";
352 $tabfieldvalue[30] = "code,name,paper_size,orientation,metric,leftmargin,topmargin,nx,ny,spacex,spacey,width,height,font_size,custom_x,custom_y";
353 //$tabfieldvalue[31]= "pcg_version,label";
354 $tabfieldvalue[32] = "code,dayrule,day,month,year,country";
355 $tabfieldvalue[33] = "code,label";
356 $tabfieldvalue[34] = "code,label";
357 $tabfieldvalue[35] = "label";
358 $tabfieldvalue[36] = "range_ik,fk_c_exp_tax_cat";
359 $tabfieldvalue[37] = "code,label,short_label,unit_type,scale";
360 $tabfieldvalue[38] = "code,label,url,icon";
361 $tabfieldvalue[39] = "code,libelle,sortorder";
362 $tabfieldvalue[40] = "code,libelle,picto";
363 $tabfieldvalue[41] = "code,label";
364 $tabfieldvalue[42] = "code,label";
365 
366 // Field names in the table for inserting a record
367 $tabfieldinsert = array();
368 $tabfieldinsert[1] = "code,libelle,fk_pays";
369 $tabfieldinsert[2] = "code_departement,nom,fk_region";
370 $tabfieldinsert[3] = "code_region,nom,fk_pays";
371 $tabfieldinsert[4] = "code,label";
372 $tabfieldinsert[5] = "code,label";
373 $tabfieldinsert[6] = "code,libelle,type,color,position";
374 $tabfieldinsert[7] = "code,libelle,fk_pays,accountancy_code,deductible";
375 $tabfieldinsert[8] = "code,libelle,fk_country".(!empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? ',position' : '');
376 $tabfieldinsert[9] = "code_iso,label,unicode";
377 $tabfieldinsert[10] = "fk_pays,code,taux,localtax1_type,localtax1,localtax2_type,localtax2,recuperableonly,accountancy_code_sell,accountancy_code_buy,note";
378 $tabfieldinsert[11] = "element,source,code,libelle,position";
379 $tabfieldinsert[12] = "code,libelle,libelle_facture,nbjour,type_cdr,decalage,sortorder,entity";
380 $tabfieldinsert[13] = "code,libelle,type,entity";
381 $tabfieldinsert[14] = "code,label,price,organization,fk_pays";
382 $tabfieldinsert[15] = "code,label,width,height,unit";
383 $tabfieldinsert[16] = "code,label,sortorder";
384 $tabfieldinsert[17] = "code,label,accountancy_code";
385 $tabfieldinsert[18] = "code,libelle,tracking";
386 $tabfieldinsert[19] = "code,libelle";
387 $tabfieldinsert[20] = "code,libelle";
388 $tabfieldinsert[21] = "code,label";
389 $tabfieldinsert[22] = "code,label";
390 $tabfieldinsert[23] = "fk_pays,taux,revenuestamp_type,accountancy_code_sell,accountancy_code_buy,note";
391 $tabfieldinsert[24] = "code,label";
392 $tabfieldinsert[25] = "code,label";
393 //$tabfieldinsert[26]= "code,label,short_label";
394 $tabfieldinsert[27] = "code,libelle,picto";
395 $tabfieldinsert[28] = "code,label,affect,delay,newbymonth,fk_country";
396 $tabfieldinsert[29] = "code,label,percent,position";
397 $tabfieldinsert[30] = "code,name,paper_size,orientation,metric,leftmargin,topmargin,nx,ny,spacex,spacey,width,height,font_size,custom_x,custom_y";
398 //$tabfieldinsert[31]= "pcg_version,label";
399 //$tabfieldinsert[32]= "code,label,range_account,sens,category_type,formula,position,fk_country";
400 $tabfieldinsert[32] = "code,dayrule,day,month,year,fk_country";
401 $tabfieldinsert[33] = "code,label";
402 $tabfieldinsert[34] = "code,label";
403 $tabfieldinsert[35] = "label";
404 $tabfieldinsert[36] = "range_ik,fk_c_exp_tax_cat";
405 $tabfieldinsert[37] = "code,label,short_label,unit_type,scale";
406 $tabfieldinsert[38] = "code,label,url,icon,entity";
407 $tabfieldinsert[39] = "code,label,sortorder";
408 $tabfieldinsert[40] = "code,libelle,picto";
409 $tabfieldinsert[41] = "code,label";
410 $tabfieldinsert[42] = "code,label";
411 
412 // Rowid name of field depending if field is autoincrement on or off..
413 // Use "" if id field is "rowid" and has autoincrement on
414 // Use "nameoffield" if id field is not "rowid" or has not autoincrement on
415 $tabrowid = array();
416 $tabrowid[1] = "";
417 $tabrowid[2] = "";
418 $tabrowid[3] = "";
419 $tabrowid[4] = "rowid";
420 $tabrowid[5] = "rowid";
421 $tabrowid[6] = "id";
422 $tabrowid[7] = "id";
423 $tabrowid[8] = "id";
424 $tabrowid[9] = "code_iso";
425 $tabrowid[10] = "";
426 $tabrowid[11] = "rowid";
427 $tabrowid[12] = "";
428 $tabrowid[13] = "id";
429 $tabrowid[14] = "";
430 $tabrowid[15] = "";
431 $tabrowid[16] = "code";
432 $tabrowid[17] = "id";
433 $tabrowid[18] = "rowid";
434 $tabrowid[19] = "id";
435 $tabrowid[20] = "";
436 $tabrowid[21] = "rowid";
437 $tabrowid[22] = "rowid";
438 $tabrowid[23] = "";
439 $tabrowid[24] = "";
440 $tabrowid[25] = "";
441 //$tabrowid[26]= "";
442 $tabrowid[27] = "id";
443 $tabrowid[28] = "";
444 $tabrowid[29] = "";
445 $tabrowid[30] = "";
446 //$tabrowid[31]= "";
447 $tabrowid[32] = "id";
448 $tabrowid[33] = "rowid";
449 $tabrowid[34] = "rowid";
450 $tabrowid[35] = "";
451 $tabrowid[36] = "";
452 $tabrowid[37] = "";
453 $tabrowid[38] = "";
454 $tabrowid[39] = "code";
455 $tabrowid[40] = "id";
456 $tabrowid[41] = "";
457 $tabrowid[42] = "rowid";
458 
459 // Condition to show dictionary in setup page
460 $tabcond = array();
461 $tabcond[1] = (!empty($conf->societe->enabled));
462 $tabcond[2] = true;
463 $tabcond[3] = true;
464 $tabcond[4] = true;
465 $tabcond[5] = (!empty($conf->societe->enabled) || !empty($conf->adherent->enabled));
466 $tabcond[6] = !empty($conf->agenda->enabled);
467 $tabcond[7] = !empty($conf->tax->enabled);
468 $tabcond[8] = !empty($conf->societe->enabled);
469 $tabcond[9] = true;
470 $tabcond[10] = true;
471 $tabcond[11] = (!empty($conf->societe->enabled));
472 $tabcond[12] = (!empty($conf->commande->enabled) || !empty($conf->propal->enabled) || !empty($conf->facture->enabled) || (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_invoice->enabled) || !empty($conf->supplier_order->enabled));
473 $tabcond[13] = (!empty($conf->commande->enabled) || !empty($conf->propal->enabled) || !empty($conf->facture->enabled) || (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_invoice->enabled) || !empty($conf->supplier_order->enabled));
474 $tabcond[14] = (!empty($conf->product->enabled) && (!empty($conf->ecotax->enabled) || !empty($conf->global->MAIN_SHOW_ECOTAX_DICTIONNARY)));
475 $tabcond[15] = true;
476 $tabcond[16] = (!empty($conf->societe->enabled) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS));
477 $tabcond[17] = (!empty($conf->deplacement->enabled) || !empty($conf->expensereport->enabled));
478 $tabcond[18] = !empty($conf->expedition->enabled) || !empty($conf->reception->enabled);
479 $tabcond[19] = !empty($conf->societe->enabled);
480 $tabcond[20] = (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled));
481 $tabcond[21] = !empty($conf->propal->enabled);
482 $tabcond[22] = (!empty($conf->commande->enabled) || !empty($conf->propal->enabled));
483 $tabcond[23] = true;
484 $tabcond[24] = !empty($conf->resource->enabled);
485 $tabcond[25] = !empty($conf->website->enabled);
486 //$tabcond[26]= ! empty($conf->product->enabled);
487 $tabcond[27] = !empty($conf->societe->enabled);
488 $tabcond[28] = !empty($conf->holiday->enabled);
489 $tabcond[29] = !empty($conf->projet->enabled);
490 $tabcond[30] = !empty($conf->label->enabled);
491 //$tabcond[31]= ! empty($conf->accounting->enabled);
492 $tabcond[32] = (!empty($conf->holiday->enabled) || !empty($conf->hrm->enabled));
493 $tabcond[33] = !empty($conf->hrm->enabled);
494 $tabcond[34] = !empty($conf->hrm->enabled);
495 $tabcond[35] = !empty($conf->expensereport->enabled);
496 $tabcond[36] = !empty($conf->expensereport->enabled);
497 $tabcond[37] = !empty($conf->product->enabled);
498 $tabcond[38] = !empty($conf->socialnetworks->enabled);
499 $tabcond[39] = (!empty($conf->societe->enabled) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && !empty($conf->global->THIRDPARTY_ENABLE_PROSPECTION_ON_ALTERNATIVE_ADRESSES));
500 $tabcond[40] = (!empty($conf->societe->enabled) && !empty($conf->global->THIRDPARTY_ENABLE_PROSPECTION_ON_ALTERNATIVE_ADRESSES));
501 $tabcond[41] = !empty($conf->intracommreport->enabled);
502 $tabcond[42] = !empty($conf->product->enabled);
503 
504 // List of help for fields
505 $tabhelp = array();
506 $tabhelp[1] = array('code'=>$langs->trans("EnterAnyCode"));
507 $tabhelp[2] = array('code'=>$langs->trans("EnterAnyCode"));
508 $tabhelp[3] = array('code'=>$langs->trans("EnterAnyCode"));
509 $tabhelp[4] = array('code'=>$langs->trans("EnterAnyCode"));
510 $tabhelp[5] = array('code'=>$langs->trans("EnterAnyCode"));
511 $tabhelp[6] = array('code'=>$langs->trans("EnterAnyCode"), 'color'=>$langs->trans("ColorFormat"), 'position'=>$langs->trans("PositionIntoComboList"));
512 $tabhelp[7] = array('code'=>$langs->trans("EnterAnyCode"));
513 $tabhelp[8] = array('code'=>$langs->trans("EnterAnyCode"), 'position'=>$langs->trans("PositionIntoComboList"));
514 $tabhelp[9] = array('code'=>$langs->trans("EnterAnyCode"), 'unicode'=>$langs->trans("UnicodeCurrency"));
515 $tabhelp[10] = array('code'=>$langs->trans("EnterAnyCode"), 'taux'=>$langs->trans("SellTaxRate"), 'recuperableonly'=>$langs->trans("RecuperableOnly"), 'localtax1_type'=>$langs->trans("LocalTaxDesc"), 'localtax2_type'=>$langs->trans("LocalTaxDesc"));
516 $tabhelp[11] = array('code'=>$langs->trans("EnterAnyCode"), 'position'=>$langs->trans("PositionIntoComboList"));
517 $tabhelp[12] = array('code'=>$langs->trans("EnterAnyCode"), 'type_cdr'=>$langs->trans("TypeCdr", $langs->transnoentitiesnoconv("NbOfDays"), $langs->transnoentitiesnoconv("Offset"), $langs->transnoentitiesnoconv("NbOfDays"), $langs->transnoentitiesnoconv("Offset")));
518 $tabhelp[13] = array('code'=>$langs->trans("EnterAnyCode"));
519 $tabhelp[14] = array('code'=>$langs->trans("EnterAnyCode"));
520 $tabhelp[15] = array('code'=>$langs->trans("EnterAnyCode"));
521 $tabhelp[16] = array('code'=>$langs->trans("EnterAnyCode"));
522 $tabhelp[17] = array('code'=>$langs->trans("EnterAnyCode"));
523 $tabhelp[18] = array('code'=>$langs->trans("EnterAnyCode"), 'tracking'=>$langs->trans("UrlTrackingDesc"));
524 $tabhelp[19] = array('code'=>$langs->trans("EnterAnyCode"));
525 $tabhelp[20] = array('code'=>$langs->trans("EnterAnyCode"));
526 $tabhelp[21] = array('code'=>$langs->trans("EnterAnyCode"));
527 $tabhelp[22] = array('code'=>$langs->trans("EnterAnyCode"));
528 $tabhelp[23] = array('revenuestamp_type'=>'FixedOrPercent');
529 $tabhelp[24] = array('code'=>$langs->trans("EnterAnyCode"));
530 $tabhelp[25] = array('code'=>$langs->trans('EnterAnyCode'));
531 //$tabhelp[26] = array('code'=>$langs->trans("EnterAnyCode"));
532 $tabhelp[27] = array('code'=>$langs->trans("EnterAnyCode"), 'picto'=>$langs->trans("PictoHelp"));
533 $tabhelp[28] = array('affect'=>$langs->trans("FollowedByACounter"), 'delay'=>$langs->trans("MinimumNoticePeriod"), 'newbymonth'=>$langs->trans("NbAddedAutomatically"));
534 $tabhelp[29] = array('code'=>$langs->trans("EnterAnyCode"), 'percent'=>$langs->trans("OpportunityPercent"), 'position'=>$langs->trans("PositionIntoComboList"));
535 $tabhelp[30] = array('code'=>$langs->trans("EnterAnyCode"), 'name'=>$langs->trans("LabelName"), 'paper_size'=>$langs->trans("LabelPaperSize"));
536 //$tabhelp[31] = array('pcg_version'=>$langs->trans("EnterAnyCode"));
537 $tabhelp[32] = 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"));
538 $tabhelp[33] = array('code'=>$langs->trans("EnterAnyCode"));
539 $tabhelp[34] = array('code'=>$langs->trans("EnterAnyCode"));
540 $tabhelp[35] = array();
541 $tabhelp[36] = array('range_ik'=>$langs->trans('PrevRangeToThisRange'));
542 $tabhelp[37] = array('code'=>$langs->trans("EnterAnyCode"), 'unit_type' => $langs->trans('MeasuringUnitTypeDesc'), 'scale' => $langs->trans('MeasuringScaleDesc'));
543 $tabhelp[38] = array('code'=>$langs->trans("EnterAnyCode"), 'url' => $langs->trans('UrlSocialNetworksDesc'), 'icon' => $langs->trans('FafaIconSocialNetworksDesc'));
544 $tabhelp[39] = array('code'=>$langs->trans("EnterAnyCode"));
545 $tabhelp[40] = array('code'=>$langs->trans("EnterAnyCode"), 'picto'=>$langs->trans("PictoHelp"));
546 $tabhelp[41] = array('code'=>$langs->trans("EnterAnyCode"));
547 $tabhelp[42] = array('code'=>$langs->trans("EnterAnyCode"));
548 
549 // List of check for fields (NOT USED YET)
550 $tabfieldcheck = array();
551 $tabfieldcheck[1] = array();
552 $tabfieldcheck[2] = array();
553 $tabfieldcheck[3] = array();
554 $tabfieldcheck[4] = array();
555 $tabfieldcheck[5] = array();
556 $tabfieldcheck[6] = array();
557 $tabfieldcheck[7] = array();
558 $tabfieldcheck[8] = array();
559 $tabfieldcheck[9] = array();
560 $tabfieldcheck[10] = array();
561 $tabfieldcheck[11] = array();
562 $tabfieldcheck[12] = array();
563 $tabfieldcheck[13] = array();
564 $tabfieldcheck[14] = array();
565 $tabfieldcheck[15] = array();
566 $tabfieldcheck[16] = array();
567 $tabfieldcheck[17] = array();
568 $tabfieldcheck[18] = array();
569 $tabfieldcheck[19] = array();
570 $tabfieldcheck[20] = array();
571 $tabfieldcheck[21] = array();
572 $tabfieldcheck[22] = array();
573 $tabfieldcheck[23] = array();
574 $tabfieldcheck[24] = array();
575 $tabfieldcheck[25] = array();
576 //$tabfieldcheck[26] = array();
577 $tabfieldcheck[27] = array();
578 $tabfieldcheck[28] = array();
579 $tabfieldcheck[29] = array();
580 $tabfieldcheck[30] = array();
581 //$tabfieldcheck[31] = array();
582 $tabfieldcheck[32] = array();
583 $tabfieldcheck[33] = array();
584 $tabfieldcheck[34] = array();
585 $tabfieldcheck[35] = array();
586 $tabfieldcheck[36] = array();
587 $tabfieldcheck[37] = array();
588 $tabfieldcheck[38] = array();
589 $tabfieldcheck[39] = array();
590 $tabfieldcheck[40] = array();
591 $tabfieldcheck[41] = array();
592 $tabfieldcheck[42] = array();
593 
594 // Complete all arrays with entries found into modules
595 complete_dictionary_with_modules($taborder, $tabname, $tablib, $tabsql, $tabsqlsort, $tabfield, $tabfieldvalue, $tabfieldinsert, $tabrowid, $tabcond, $tabhelp, $tabfieldcheck);
596 
597 
598 // Defaut sortorder
599 if (empty($sortfield))
600 {
601  $tmp1 = explode(',', $tabsqlsort[$id]);
602  $tmp2 = explode(' ', $tmp1[0]);
603  $sortfield = preg_replace('/^.*\./', '', $tmp2[0]);
604 }
605 
606 // Define elementList and sourceList (used for dictionary type of contacts "llx_c_type_contact")
607 $elementList = array();
608 $sourceList = array();
609 if ($id == 11)
610 {
611  $elementList = array(
612  '' => '',
613  'societe' => $langs->trans('ThirdParty'),
614  // 'proposal' => $langs->trans('Proposal'),
615  // 'order' => $langs->trans('Order'),
616  // 'invoice' => $langs->trans('Bill'),
617  'supplier_proposal' => $langs->trans('SupplierProposal'),
618  'order_supplier' => $langs->trans('SupplierOrder'),
619  'invoice_supplier' => $langs->trans('SupplierBill'),
620  // 'intervention' => $langs->trans('InterventionCard'),
621  // 'contract' => $langs->trans('Contract'),
622  'project' => $langs->trans('Project'),
623  'project_task' => $langs->trans('Task'),
624  'ticket' => $langs->trans('Ticket'),
625  'agenda' => $langs->trans('Agenda'),
626  'dolresource' => $langs->trans('Resource'),
627  // old deprecated
628  'propal' => $langs->trans('Proposal'),
629  'commande' => $langs->trans('Order'),
630  'facture' => $langs->trans('Bill'),
631  'fichinter' => $langs->trans('InterventionCard'),
632  'contrat' => $langs->trans('Contract'),
633  );
634  if (!empty($conf->global->MAIN_SUPPORT_SHARED_CONTACT_BETWEEN_THIRDPARTIES)) $elementList["societe"] = $langs->trans('ThirdParty');
635 
636  complete_elementList_with_modules($elementList);
637 
638  asort($elementList);
639  $sourceList = array(
640  'internal' => $langs->trans('Internal'),
641  'external' => $langs->trans('External')
642  );
643 }
644 
645 // Define localtax_typeList (used for dictionary "llx_c_tva")
646 $localtax_typeList = array();
647 if ($id == 10)
648 {
649  $localtax_typeList = array(
650  "0" => $langs->trans("No"),
651  "1" => $langs->trans("Yes").' ('.$langs->trans("Type")." 1)", //$langs->trans("%ageOnAllWithoutVAT"),
652  "2" => $langs->trans("Yes").' ('.$langs->trans("Type")." 2)", //$langs->trans("%ageOnAllBeforeVAT"),
653  "3" => $langs->trans("Yes").' ('.$langs->trans("Type")." 3)", //$langs->trans("%ageOnProductsWithoutVAT"),
654  "4" => $langs->trans("Yes").' ('.$langs->trans("Type")." 4)", //$langs->trans("%ageOnProductsBeforeVAT"),
655  "5" => $langs->trans("Yes").' ('.$langs->trans("Type")." 5)", //$langs->trans("%ageOnServiceWithoutVAT"),
656  "6" => $langs->trans("Yes").' ('.$langs->trans("Type")." 6)" //$langs->trans("%ageOnServiceBeforeVAT"),
657  );
658 }
659 
660 
661 
662 /*
663  * Actions
664  */
665 
666 if (GETPOST('button_removefilter', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter_x', 'alpha'))
667 {
668  $search_country_id = '';
669  $search_code = '';
670 }
671 
672 // Actions add or modify an entry into a dictionary
673 if (GETPOST('actionadd') || GETPOST('actionmodify'))
674 {
675  $listfield = explode(',', str_replace(' ', '', $tabfield[$id]));
676  $listfieldinsert = explode(',', $tabfieldinsert[$id]);
677  $listfieldmodify = explode(',', $tabfieldinsert[$id]);
678  $listfieldvalue = explode(',', $tabfieldvalue[$id]);
679 
680  // Check that all fields are filled
681  $ok = 1;
682  foreach ($listfield as $f => $value)
683  {
684  // Discard check of mandatory fields for country for some tables
685  if ($value == 'country_id' && in_array($tablib[$id], array('DictionaryPublicHolidays', 'DictionaryVAT', 'DictionaryRegion', 'DictionaryCompanyType', 'DictionaryHolidayTypes', 'DictionaryRevenueStamp', 'DictionaryAccountancysystem', 'DictionaryAccountancyCategory'))) continue; // For some pages, country is not mandatory
686  if ($value == 'country' && in_array($tablib[$id], array('DictionaryPublicHolidays', 'DictionaryCanton', 'DictionaryCompanyType', 'DictionaryHolidayTypes', 'DictionaryRevenueStamp'))) continue; // For some pages, country is not mandatory
687  // Discard check of mandatory fiedls for other fields
688  if ($value == 'localtax1' && empty($_POST['localtax1_type'])) continue;
689  if ($value == 'localtax2' && empty($_POST['localtax2_type'])) continue;
690  if ($value == 'color' && empty($_POST['color'])) continue;
691  if ($value == 'formula' && empty($_POST['formula'])) continue;
692  if ($value == 'dayrule' && empty($_POST['dayrule'])) continue;
693  if ($value == 'sortorder') continue; // For a column name 'sortorder', we use the field name 'position'
694  if ((!GETPOSTISSET($value) || GETPOST($value) == '')
695  && (!in_array($listfield[$f], array('decalage', 'module', 'accountancy_code', 'accountancy_code_sell', 'accountancy_code_buy', 'tracking', 'picto')) // Fields that are not mandatory
696  && ($id != 10 || ($listfield[$f] != 'code' && $listfield[$f] != 'note')) // Field code and note is not mandatory for dictionary table 10
697  )
698  ) {
699  $ok = 0;
700  $fieldnamekey = $listfield[$f];
701  // We take translate key of field
702  if ($fieldnamekey == 'libelle' || ($fieldnamekey == 'label')) $fieldnamekey = 'Label';
703  if ($fieldnamekey == 'libelle_facture') $fieldnamekey = 'LabelOnDocuments';
704  if ($fieldnamekey == 'nbjour') $fieldnamekey = 'NbOfDays';
705  if ($fieldnamekey == 'decalage') $fieldnamekey = 'Offset';
706  if ($fieldnamekey == 'module') $fieldnamekey = 'Module';
707  if ($fieldnamekey == 'code') $fieldnamekey = 'Code';
708  if ($fieldnamekey == 'note') $fieldnamekey = 'Note';
709  if ($fieldnamekey == 'taux') $fieldnamekey = 'Rate';
710  if ($fieldnamekey == 'type') $fieldnamekey = 'Type';
711  if ($fieldnamekey == 'position') $fieldnamekey = 'Position';
712  if ($fieldnamekey == 'unicode') $fieldnamekey = 'Unicode';
713  if ($fieldnamekey == 'deductible') $fieldnamekey = 'Deductible';
714  if ($fieldnamekey == 'sortorder') $fieldnamekey = 'SortOrder';
715  if ($fieldnamekey == 'category_type') $fieldnamekey = 'Calculated';
716  if ($fieldnamekey == 'revenuestamp_type') $fieldnamekey = 'TypeOfRevenueStamp';
717  if ($fieldnamekey == 'use_default') $fieldnamekey = 'UseByDefault';
718 
719  setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentities($fieldnamekey)), null, 'errors');
720  }
721  }
722  // Other checks
723  if (GETPOST('actionadd') && $tabname[$id] == MAIN_DB_PREFIX."c_actioncomm" && GETPOSTISSET("type") && in_array(GETPOST("type"), array('system', 'systemauto'))) {
724  $ok = 0;
725  setEventMessages($langs->transnoentities('ErrorReservedTypeSystemSystemAuto'), null, 'errors');
726  }
727  if (GETPOSTISSET("code"))
728  {
729  if (GETPOST("code") == '0')
730  {
731  $ok = 0;
732  setEventMessages($langs->transnoentities('ErrorCodeCantContainZero'), null, 'errors');
733  }
734  /*if (!is_numeric($_POST['code'])) // disabled, code may not be in numeric base
735  {
736  $ok = 0;
737  $msg .= $langs->transnoentities('ErrorFieldFormat', $langs->transnoentities('Code')).'<br>';
738  }*/
739  }
740  if (GETPOSTISSET("country") && ($_POST["country"] == '0') && ($id != 2))
741  {
742  if (in_array($tablib[$id], array('DictionaryCompanyType', 'DictionaryHolidayTypes'))) // Field country is no mandatory for such dictionaries
743  {
744  $_POST["country"] = '';
745  } else {
746  $ok = 0;
747  setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentities("Country")), null, 'errors');
748  }
749  }
750  if (($id == 3 || $id == 42) && !is_numeric($_POST["code"])) {
751  $ok = 0;
752  setEventMessages($langs->transnoentities("ErrorFieldMustBeANumeric", $langs->transnoentities("Code")), null, 'errors');
753  }
754 
755  // Clean some parameters
756  if ((!empty($_POST["localtax1_type"]) || ($_POST['localtax1_type'] == '0')) && empty($_POST["localtax1"])) $_POST["localtax1"] = '0'; // If empty, we force to 0
757  if ((!empty($_POST["localtax2_type"]) || ($_POST['localtax2_type'] == '0')) && empty($_POST["localtax2"])) $_POST["localtax2"] = '0'; // If empty, we force to 0
758  if ($_POST["accountancy_code"] <= 0) $_POST["accountancy_code"] = ''; // If empty, we force to null
759  if ($_POST["accountancy_code_sell"] <= 0) $_POST["accountancy_code_sell"] = ''; // If empty, we force to null
760  if ($_POST["accountancy_code_buy"] <= 0) $_POST["accountancy_code_buy"] = ''; // If empty, we force to null
761  if ($id == 10 && GETPOSTISSET("code")) // Spaces are not allowed into code for tax dictionary
762  {
763  $_POST["code"] = preg_replace('/[^a-zA-Z0-9\-\+]/', '', $_POST["code"]);
764  }
765 
766  // If check ok and action add, add the line
767  if ($ok && GETPOST('actionadd'))
768  {
769  if ($tabrowid[$id])
770  {
771  // Get free id for insert
772  $newid = 0;
773  $sql = "SELECT max(".$tabrowid[$id].") newid from ".$tabname[$id];
774  $result = $db->query($sql);
775  if ($result)
776  {
777  $obj = $db->fetch_object($result);
778  $newid = ($obj->newid + 1);
779  } else {
780  dol_print_error($db);
781  }
782  }
783 
784  // Add new entry
785  $sql = "INSERT INTO ".$tabname[$id]." (";
786  // List of fields
787  if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldinsert))
788  $sql .= $tabrowid[$id].",";
789  $sql .= $tabfieldinsert[$id];
790  $sql .= ",active)";
791  $sql .= " VALUES(";
792 
793  // List of values
794  if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldinsert))
795  $sql .= $newid.",";
796  $i = 0;
797  foreach ($listfieldinsert as $f => $value)
798  {
799  $keycode = $listfieldvalue[$i];
800  if (empty($keycode)) $keycode = $value;
801 
802  if ($value == 'price' || preg_match('/^amount/i', $value)) {
803  $_POST[$keycode] = price2num(GETPOST($keycode), 'MU');
804  }
805  elseif ($value == 'taux' || $value == 'localtax1' || $value == 'localtax2') {
806  $_POST[$keycode] = price2num(GETPOST($keycode), 8);
807  }
808  elseif ($value == 'entity') {
809  $_POST[$keycode] = getEntity($tabname[$id]);
810  }
811 
812  if ($i) $sql .= ",";
813 
814  if ($keycode == 'sortorder') // For column name 'sortorder', we use the field name 'position'
815  {
816  $sql .= "'".(int) GETPOST('position', 'int')."'";
817  } elseif ($_POST[$keycode] == '' && !($keycode == 'code' && $id == 10)) $sql .= "null"; // For vat, we want/accept code = ''
818  elseif ($keycode == 'content') {
819  $sql .= "'".$db->escape(GETPOST($keycode, 'restricthtml'))."'";
820  } elseif (in_array($keycode, array('joinfile', 'private', 'position', 'scale'))) {
821  $sql .= (int) GETPOST($keycode, 'int');
822  } else {
823  $sql .= "'".$db->escape(GETPOST($keycode, 'nohtml'))."'";
824  }
825 
826  $i++;
827  }
828  $sql .= ",1)";
829 
830  dol_syslog("actionadd", LOG_DEBUG);
831  $result = $db->query($sql);
832  if ($result) // Add is ok
833  {
834  setEventMessages($langs->transnoentities("RecordCreatedSuccessfully"), null, 'mesgs');
835 
836  // Clean $_POST array, we keep only id of dictionary
837  if ($id == 10 && GETPOST('country', 'int') > 0) {
838  $search_country_id = GETPOST('country', 'int');
839  }
840  $_POST = array('id'=>$id);
841  } else {
842  if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
843  setEventMessages($langs->transnoentities("ErrorRecordAlreadyExists"), null, 'errors');
844  } else {
845  dol_print_error($db);
846  }
847  }
848  }
849 
850  // If verif ok and action modify, modify the line
851  if ($ok && GETPOST('actionmodify'))
852  {
853  if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; }
854 
855  // Modify entry
856  $sql = "UPDATE ".$tabname[$id]." SET ";
857  // Modifie valeur des champs
858  if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldmodify))
859  {
860  $sql .= $tabrowid[$id]."=";
861  $sql .= "'".$db->escape($rowid)."', ";
862  }
863  $i = 0;
864  foreach ($listfieldmodify as $field)
865  {
866  $keycode = $listfieldvalue[$i];
867  if (empty($keycode)) $keycode = $field;
868 
869  if ($field == 'price' || preg_match('/^amount/i', $field)) {
870  $_POST[$keycode] = price2num(GETPOST($keycode), 'MU');
871  }
872  elseif ($field == 'taux' || $field == 'localtax1' || $field == 'localtax2') {
873  $_POST[$keycode] = price2num(GETPOST($keycode), 8);
874  }
875  elseif ($field == 'entity') {
876  $_POST[$keycode] = getEntity($tabname[$id]);
877  }
878 
879  if ($i) $sql .= ",";
880  $sql .= $field."=";
881  if ($listfieldvalue[$i] == 'sortorder') // For column name 'sortorder', we use the field name 'position'
882  {
883  $sql .= (int) GETPOST('position', 'int');
884  } elseif ($_POST[$keycode] == '' && !($keycode == 'code' && $id == 10)) $sql .= "null"; // For vat, we want/accept code = ''
885  elseif ($keycode == 'content') {
886  $sql .= "'".$db->escape(GETPOST($keycode, 'restricthtml'))."'";
887  } elseif (in_array($keycode, array('private', 'position', 'scale'))) {
888  $sql .= (int) GETPOST($keycode, 'int');
889  } else {
890  $sql .= "'".$db->escape(GETPOST($keycode, 'nohtml'))."'";
891  }
892 
893  $i++;
894  }
895  if (in_array($rowidcol, array('code', 'code_iso'))) {
896  $sql .= " WHERE ".$rowidcol." = '".$db->escape($rowid)."'";
897  } else {
898  $sql .= " WHERE ".$rowidcol." = ".((int) $rowid);
899  }
900  if (in_array('entity', $listfieldmodify)) $sql .= " AND entity = '".getEntity($tabname[$id])."'";
901 
902  dol_syslog("actionmodify", LOG_DEBUG);
903  //print $sql;
904  $resql = $db->query($sql);
905  if (!$resql)
906  {
907  setEventMessages($db->error(), null, 'errors');
908  }
909  }
910  //$_GET["id"]=GETPOST('id', 'int'); // Force affichage dictionnaire en cours d'edition
911 }
912 
913 if (GETPOST('actioncancel'))
914 {
915  //$_GET["id"]=GETPOST('id', 'int'); // Force affichage dictionnaire en cours d'edition
916 }
917 
918 if ($action == 'confirm_delete' && $confirm == 'yes') // delete
919 {
920  if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; }
921 
922  $sql = "DELETE FROM ".$tabname[$id]." WHERE ".$rowidcol."='".$db->escape($rowid)."'".($entity != '' ? " AND entity = ".(int) $entity : '');
923 
924  dol_syslog("delete", LOG_DEBUG);
925  $result = $db->query($sql);
926  if (!$result)
927  {
928  if ($db->errno() == 'DB_ERROR_CHILD_EXISTS')
929  {
930  setEventMessages($langs->transnoentities("ErrorRecordIsUsedByChild"), null, 'errors');
931  } else {
932  dol_print_error($db);
933  }
934  }
935 }
936 
937 // activate
938 if ($action == $acts[0])
939 {
940  if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; }
941 
942  if ($rowid) {
943  $sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE ".$rowidcol."='".$db->escape($rowid)."'".($entity != '' ? " AND entity = ".(int) $entity : '');
944  } elseif ($code) {
945  $sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE code='".dol_escape_htmltag($code)."'".($entity != '' ? " AND entity = ".(int) $entity : '');
946  }
947 
948  $result = $db->query($sql);
949  if (!$result)
950  {
951  dol_print_error($db);
952  }
953 }
954 
955 // disable
956 if ($action == $acts[1])
957 {
958  if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; }
959 
960  if ($rowid) {
961  $sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE ".$rowidcol."='".$db->escape($rowid)."'".($entity != '' ? " AND entity = ".(int) $entity : '');
962  } elseif ($code) {
963  $sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE code='".dol_escape_htmltag($code)."'".($entity != '' ? " AND entity = ".(int) $entity : '');
964  }
965 
966  $result = $db->query($sql);
967  if (!$result)
968  {
969  dol_print_error($db);
970  }
971 }
972 
973 // favorite
974 if ($action == 'activate_favorite')
975 {
976  if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; }
977 
978  if ($rowid) {
979  $sql = "UPDATE ".$tabname[$id]." SET favorite = 1 WHERE ".$rowidcol."='".$db->escape($rowid)."'".($entity != '' ? " AND entity = ".(int) $entity : '');
980  } elseif ($code) {
981  $sql = "UPDATE ".$tabname[$id]." SET favorite = 1 WHERE code='".dol_escape_htmltag($code)."'".($entity != '' ? " AND entity = ".(int) $entity : '');
982  }
983 
984  $result = $db->query($sql);
985  if (!$result)
986  {
987  dol_print_error($db);
988  }
989 }
990 
991 // disable favorite
992 if ($action == 'disable_favorite')
993 {
994  if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; }
995 
996  if ($rowid) {
997  $sql = "UPDATE ".$tabname[$id]." SET favorite = 0 WHERE ".$rowidcol."='".$db->escape($rowid)."'".($entity != '' ? " AND entity = ".(int) $entity : '');
998  } elseif ($code) {
999  $sql = "UPDATE ".$tabname[$id]." SET favorite = 0 WHERE code='".dol_escape_htmltag($code)."'".($entity != '' ? " AND entity = ".(int) $entity : '');
1000  }
1001 
1002  $result = $db->query($sql);
1003  if (!$result)
1004  {
1005  dol_print_error($db);
1006  }
1007 }
1008 
1009 
1010 /*
1011  * View
1012  */
1013 
1014 $form = new Form($db);
1015 $formadmin = new FormAdmin($db);
1016 
1017 $title = $langs->trans("DictionarySetup");
1018 
1019 llxHeader('', $title);
1020 
1021 $linkback = '';
1022 if ($id)
1023 {
1024  $title .= ' - '.$langs->trans($tablib[$id]);
1025  $linkback = '<a href="'.$_SERVER['PHP_SELF'].'">'.$langs->trans("BackToDictionaryList").'</a>';
1026 }
1027 $titlepicto = 'title_setup';
1028 if ($id == 10 && GETPOST('from') == 'accountancy')
1029 {
1030  $title = $langs->trans("MenuVatAccounts");
1031  $titlepicto = 'accountancy';
1032 }
1033 if ($id == 7 && GETPOST('from') == 'accountancy')
1034 {
1035  $title = $langs->trans("MenuTaxAccounts");
1036  $titlepicto = 'accountancy';
1037 }
1038 
1039 print load_fiche_titre($title, $linkback, $titlepicto);
1040 
1041 if (empty($id))
1042 {
1043  print '<span class="opacitymedium">'.$langs->trans("DictionaryDesc");
1044  print " ".$langs->trans("OnlyActiveElementsAreShown")."<br>\n";
1045  print '</span><br>';
1046 }
1047 
1048 
1049 $param = '&id='.urlencode($id);
1050 if ($search_country_id > 0) $param .= '&search_country_id='.urlencode($search_country_id);
1051 if ($search_code != '') $param .= '&search_code='.urlencode($search_country_id);
1052 if ($entity != '') $param .= '&entity='.(int) $entity;
1053 $paramwithsearch = $param;
1054 if ($sortorder) $paramwithsearch .= '&sortorder='.urlencode($sortorder);
1055 if ($sortfield) $paramwithsearch .= '&sortfield='.urlencode($sortfield);
1056 if (GETPOST('from')) $paramwithsearch .= '&from='.urlencode(GETPOST('from', 'alpha'));
1057 
1058 
1059 // Confirmation of the deletion of the line
1060 if ($action == 'delete')
1061 {
1062  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);
1063 }
1064 //var_dump($elementList);
1065 
1066 /*
1067  * Show a dictionary
1068  */
1069 if ($id)
1070 {
1071  // Complete search values request with sort criteria
1072  $sql = $tabsql[$id];
1073 
1074  if (!preg_match('/ WHERE /', $sql)) $sql .= " WHERE 1 = 1";
1075  if ($search_country_id > 0) $sql .= " AND c.rowid = ".$search_country_id;
1076  if ($search_code != '' && $id == 9) $sql .= natural_search("code_iso", $search_code);
1077  elseif ($search_code != '' && $id == 28) $sql .= natural_search("h.code", $search_code);
1078  elseif ($search_code != '' && $id == 32) $sql .= natural_search("a.code", $search_code);
1079  elseif ($search_code != '' && $id == 3) $sql .= natural_search("r.code_region", $search_code);
1080  elseif ($search_code != '' && $id == 7) $sql .= natural_search("a.code", $search_code);
1081  elseif ($search_code != '' && $id != 9) $sql .= natural_search("code", $search_code);
1082 
1083  if ($sortfield)
1084  {
1085  // If sort order is "country", we use country_code instead
1086  if ($sortfield == 'country') $sortfield = 'country_code';
1087  $sql .= $db->order($sortfield, $sortorder);
1088  $sql .= ", ";
1089  // Clear the required sort criteria for the tabsqlsort to be able to force it with selected value
1090  $tabsqlsort[$id] = preg_replace('/([a-z]+\.)?'.$sortfield.' '.$sortorder.',/i', '', $tabsqlsort[$id]);
1091  $tabsqlsort[$id] = preg_replace('/([a-z]+\.)?'.$sortfield.',/i', '', $tabsqlsort[$id]);
1092  } else {
1093  $sql .= " ORDER BY ";
1094  }
1095  $sql .= $tabsqlsort[$id];
1096  $sql .= $db->plimit($listlimit + 1, $offset);
1097  //print $sql;
1098 
1099  if (empty($tabfield[$id]))
1100  {
1101  dol_print_error($db, 'The table with id '.$id.' has no array tabfield defined');
1102  exit;
1103  }
1104  $fieldlist = explode(',', $tabfield[$id]);
1105 
1106  print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$id.'" method="POST">';
1107  print '<input type="hidden" name="token" value="'.newToken().'">';
1108  print '<input type="hidden" name="from" value="'.dol_escape_htmltag(GETPOST('from', 'alpha')).'">';
1109 
1110  if ($id == 10 && empty($conf->global->FACTURE_TVAOPTION))
1111  {
1112  print info_admin($langs->trans("VATIsUsedIsOff", $langs->transnoentities("Setup"), $langs->transnoentities("CompanyFoundation")));
1113  print "<br>\n";
1114  }
1115 
1116  // Form to add a new line
1117  if ($tabname[$id])
1118  {
1119  $withentity = null;
1120 
1121  $fieldlist = explode(',', $tabfield[$id]);
1122 
1123  print '<div class="div-table-responsive-no-min">';
1124  print '<table class="noborder centpercent">';
1125 
1126  // Line for title
1127  $tdsoffields = '<tr class="liste_titre">';
1128  foreach ($fieldlist as $field => $value)
1129  {
1130  if ($fieldlist[$field] == 'entity') {
1131  $withentity = getEntity($tabname[$id]);
1132  continue;
1133  }
1134 
1135  // Define field friendly name from its technical name
1136  $valuetoshow = ucfirst($fieldlist[$field]); // Par defaut
1137  $valuetoshow = $langs->trans($valuetoshow); // try to translate
1138  $class = '';
1139 
1140  if ($fieldlist[$field] == 'pos') { $valuetoshow = $langs->trans("Position"); $class = 'maxwidth100'; }
1141  if ($fieldlist[$field] == 'source') { $valuetoshow = $langs->trans("Contact"); }
1142  if ($fieldlist[$field] == 'price') { $valuetoshow = $langs->trans("PriceUHT"); }
1143  if ($fieldlist[$field] == 'taux') {
1144  if ($tabname[$id] != MAIN_DB_PREFIX."c_revenuestamp") $valuetoshow = $langs->trans("Rate");
1145  else $valuetoshow = $langs->trans("Amount");
1146  $class = 'center';
1147  }
1148  if ($fieldlist[$field] == 'localtax1_type') { $valuetoshow = $langs->trans("UseLocalTax")." 2"; $class = "center"; $sortable = 0; }
1149  if ($fieldlist[$field] == 'localtax1') { $valuetoshow = $langs->trans("Rate")." 2"; $class = "center"; }
1150  if ($fieldlist[$field] == 'localtax2_type') { $valuetoshow = $langs->trans("UseLocalTax")." 3"; $class = "center"; $sortable = 0; }
1151  if ($fieldlist[$field] == 'localtax2') { $valuetoshow = $langs->trans("Rate")." 3"; $class = "center"; }
1152  if ($fieldlist[$field] == 'organization') { $valuetoshow = $langs->trans("Organization"); }
1153  if ($fieldlist[$field] == 'lang') { $valuetoshow = $langs->trans("Language"); }
1154  if ($fieldlist[$field] == 'type') {
1155  if ($tabname[$id] == MAIN_DB_PREFIX."c_paiement") $valuetoshow = $form->textwithtooltip($langs->trans("Type"), $langs->trans("TypePaymentDesc"), 2, 1, img_help(1, ''));
1156  else $valuetoshow = $langs->trans("Type");
1157  }
1158  if ($fieldlist[$field] == 'code') { $valuetoshow = $langs->trans("Code"); $class = 'maxwidth100'; }
1159  if ($fieldlist[$field] == 'libelle' || $fieldlist[$field] == 'label')
1160  {
1161  $valuetoshow = $form->textwithtooltip($langs->trans("Label"), $langs->trans("LabelUsedByDefault"), 2, 1, img_help(1, ''));
1162  }
1163  if ($fieldlist[$field] == 'libelle_facture') {
1164  $valuetoshow = $form->textwithtooltip($langs->trans("LabelOnDocuments"), $langs->trans("LabelUsedByDefault"), 2, 1, img_help(1, ''));
1165  }
1166  if ($fieldlist[$field] == 'country') {
1167  if (in_array('region_id', $fieldlist)) { print '<td>&nbsp;</td>'; continue; } // For region page, we do not show the country input
1168  $valuetoshow = $langs->trans("Country");
1169  }
1170  if ($fieldlist[$field] == 'recuperableonly') { $valuetoshow = $langs->trans("NPR"); $class = "center"; }
1171  if ($fieldlist[$field] == 'nbjour') { $valuetoshow = $langs->trans("NbOfDays"); }
1172  if ($fieldlist[$field] == 'type_cdr') { $valuetoshow = $langs->trans("AtEndOfMonth"); $class = "center"; }
1173  if ($fieldlist[$field] == 'decalage') { $valuetoshow = $langs->trans("Offset"); }
1174  if ($fieldlist[$field] == 'width' || $fieldlist[$field] == 'nx') { $valuetoshow = $langs->trans("Width"); }
1175  if ($fieldlist[$field] == 'height' || $fieldlist[$field] == 'ny') { $valuetoshow = $langs->trans("Height"); }
1176  if ($fieldlist[$field] == 'unit' || $fieldlist[$field] == 'metric') { $valuetoshow = $langs->trans("MeasuringUnit"); }
1177  if ($fieldlist[$field] == 'region_id' || $fieldlist[$field] == 'country_id') { $valuetoshow = ''; }
1178  if ($fieldlist[$field] == 'accountancy_code') { $valuetoshow = $langs->trans("AccountancyCode"); }
1179  if ($fieldlist[$field] == 'accountancy_code_sell') { $valuetoshow = $langs->trans("AccountancyCodeSell"); }
1180  if ($fieldlist[$field] == 'accountancy_code_buy') { $valuetoshow = $langs->trans("AccountancyCodeBuy"); }
1181  if ($fieldlist[$field] == 'pcg_version' || $fieldlist[$field] == 'fk_pcg_version') { $valuetoshow = $langs->trans("Pcg_version"); }
1182  if ($fieldlist[$field] == 'account_parent') { $valuetoshow = $langs->trans("Accountparent"); }
1183  if ($fieldlist[$field] == 'pcg_type') { $valuetoshow = $langs->trans("Pcg_type"); }
1184  if ($fieldlist[$field] == 'pcg_subtype') { $valuetoshow = $langs->trans("Pcg_subtype"); }
1185  if ($fieldlist[$field] == 'sortorder') { $valuetoshow = $langs->trans("SortOrder"); }
1186  if ($fieldlist[$field] == 'short_label') { $valuetoshow = $langs->trans("ShortLabel"); }
1187  if ($fieldlist[$field] == 'range_account') { $valuetoshow = $langs->trans("Range"); }
1188  if ($fieldlist[$field] == 'sens') { $valuetoshow = $langs->trans("Sens"); }
1189  if ($fieldlist[$field] == 'category_type') { $valuetoshow = $langs->trans("Calculated"); }
1190  if ($fieldlist[$field] == 'formula') { $valuetoshow = $langs->trans("Formula"); }
1191  if ($fieldlist[$field] == 'paper_size') { $valuetoshow = $langs->trans("PaperSize"); }
1192  if ($fieldlist[$field] == 'orientation') { $valuetoshow = $langs->trans("Orientation"); }
1193  if ($fieldlist[$field] == 'leftmargin') { $valuetoshow = $langs->trans("LeftMargin"); }
1194  if ($fieldlist[$field] == 'topmargin') { $valuetoshow = $langs->trans("TopMargin"); }
1195  if ($fieldlist[$field] == 'spacex') { $valuetoshow = $langs->trans("SpaceX"); }
1196  if ($fieldlist[$field] == 'spacey') { $valuetoshow = $langs->trans("SpaceY"); }
1197  if ($fieldlist[$field] == 'font_size') { $valuetoshow = $langs->trans("FontSize"); }
1198  if ($fieldlist[$field] == 'custom_x') { $valuetoshow = $langs->trans("CustomX"); }
1199  if ($fieldlist[$field] == 'custom_y') { $valuetoshow = $langs->trans("CustomY"); }
1200  if ($fieldlist[$field] == 'percent') { $valuetoshow = $langs->trans("Percentage"); }
1201  if ($fieldlist[$field] == 'affect') { $valuetoshow = $langs->trans("WithCounter"); }
1202  if ($fieldlist[$field] == 'delay') { $valuetoshow = $langs->trans("NoticePeriod"); }
1203  if ($fieldlist[$field] == 'newbymonth') { $valuetoshow = $langs->trans("NewByMonth"); }
1204  if ($fieldlist[$field] == 'fk_tva') { $valuetoshow = $langs->trans("VAT"); }
1205  if ($fieldlist[$field] == 'range_ik') { $valuetoshow = $langs->trans("RangeIk"); }
1206  if ($fieldlist[$field] == 'fk_c_exp_tax_cat') { $valuetoshow = $langs->trans("CarCategory"); }
1207  if ($fieldlist[$field] == 'revenuestamp_type') { $valuetoshow = $langs->trans('TypeOfRevenueStamp'); }
1208  if ($fieldlist[$field] == 'use_default') { $valuetoshow = $langs->trans('Default'); $class = 'center'; }
1209  if ($fieldlist[$field] == 'unit_type') { $valuetoshow = $langs->trans('TypeOfUnit'); }
1210 
1211  if ($id == 2) // Special case for state page
1212  {
1213  if ($fieldlist[$field] == 'region_id') { $valuetoshow = '&nbsp;'; $showfield = 1; }
1214  if ($fieldlist[$field] == 'region') { $valuetoshow = $langs->trans("Country").'/'.$langs->trans("Region"); $showfield = 1; }
1215  }
1216 
1217  if ($valuetoshow != '')
1218  {
1219  $tdsoffields .= '<td'.($class ? ' class="'.$class.'"' : '').'>';
1220  if (!empty($tabhelp[$id][$value]) && preg_match('/^http(s*):/i', $tabhelp[$id][$value])) $tdsoffields .= '<a href="'.$tabhelp[$id][$value].'" target="_blank">'.$valuetoshow.' '.img_help(1, $valuetoshow).'</a>';
1221  elseif (!empty($tabhelp[$id][$value])) $tdsoffields .= $form->textwithpicto($valuetoshow, $tabhelp[$id][$value]);
1222  else $tdsoffields .= $valuetoshow;
1223  $tdsoffields .= '</td>';
1224  }
1225  }
1226 
1227  if ($id == 4) $tdsoffields .= '<td></td>';
1228  $tdsoffields .= '<td>';
1229  $tdsoffields .= '<input type="hidden" name="id" value="'.$id.'">';
1230  if (!is_null($withentity))
1231  $tdsoffields .= '<input type="hidden" name="entity" value="'.$withentity.'">';
1232  $tdsoffields .= '</td>';
1233  $tdsoffields .= '<td style="min-width: 26px;"></td>';
1234  $tdsoffields .= '<td style="min-width: 26px;"></td>';
1235  $tdsoffields .= '</tr>';
1236 
1237  print $tdsoffields;
1238 
1239 
1240  $obj = new stdClass();
1241  // If data was already input, we define them in obj to populate input fields.
1242  if (GETPOST('actionadd'))
1243  {
1244  foreach ($fieldlist as $key=>$val)
1245  {
1246  if (GETPOST($val) != '')
1247  $obj->$val = GETPOST($val);
1248  }
1249  }
1250 
1251  $tmpaction = 'create';
1252  $parameters = array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]);
1253  $reshook = $hookmanager->executeHooks('createDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
1254  $error = $hookmanager->error; $errors = $hookmanager->errors;
1255 
1256  if ($id == 3) unset($fieldlist[2]); // Remove field ??? if dictionary Regions
1257 
1258  // Line to enter new values
1259  print '<!-- line to add new entry -->';
1260  print '<tr class="oddeven nodrag nodrop nohover">';
1261 
1262  if (empty($reshook))
1263  {
1264  fieldList($fieldlist, $obj, $tabname[$id], 'add');
1265  }
1266 
1267  if ($id == 4) print '<td></td>';
1268  print '<td colspan="3" class="center">';
1269  if ($action != 'edit')
1270  {
1271  print '<input type="submit" class="button" name="actionadd" value="'.$langs->trans("Add").'">';
1272  }
1273  print '</td>';
1274 
1275  print "</tr>";
1276 
1277  print '</table>';
1278  print '</div>';
1279  }
1280 
1281  print '</form>';
1282 
1283 
1284  print '<br>';
1285 
1286 
1287  print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$id.'" method="POST">';
1288  print '<input type="hidden" name="token" value="'.newToken().'">';
1289  print '<input type="hidden" name="from" value="'.dol_escape_htmltag(GETPOST('from', 'alpha')).'">';
1290 
1291  // List of available record in database
1292  dol_syslog("htdocs/admin/dict", LOG_DEBUG);
1293 
1294  $resql = $db->query($sql);
1295  if ($resql)
1296  {
1297  $num = $db->num_rows($resql);
1298  $i = 0;
1299 
1300  // There is several pages
1301  if ($num > $listlimit || $page)
1302  {
1303  print_fleche_navigation($page, $_SERVER["PHP_SELF"], $paramwithsearch, ($num > $listlimit), '<li class="pagination"><span>'.$langs->trans("Page").' '.($page + 1).'</span></li>');
1304  print '<div class="clearboth"></div>';
1305  }
1306 
1307  print '<div class="div-table-responsive">';
1308  print '<table class="noborder centpercent">';
1309 
1310  // Title line with search input fields
1311  print '<tr class="liste_titre_filter">';
1312  $filterfound = 0;
1313  foreach ($fieldlist as $field => $value)
1314  {
1315  if ($fieldlist[$field] == 'entity') continue;
1316 
1317  $showfield = 1; // By default
1318 
1319  if ($fieldlist[$field] == 'region_id' || $fieldlist[$field] == 'country_id') { $showfield = 0; }
1320 
1321  if ($showfield)
1322  {
1323  if ($value == 'country')
1324  {
1325  print '<td class="liste_titre">';
1326  print $form->select_country($search_country_id, 'search_country_id', '', 28, 'maxwidth150 maxwidthonsmartphone');
1327  print '</td>';
1328  $filterfound++;
1329  } elseif ($value == 'code')
1330  {
1331  print '<td class="liste_titre">';
1332  print '<input type="text" class="maxwidth100" name="search_code" value="'.dol_escape_htmltag($search_code).'">';
1333  print '</td>';
1334  $filterfound++;
1335  } else {
1336  print '<td class="liste_titre">';
1337  print '</td>';
1338  }
1339  }
1340  }
1341  if ($id == 4) print '<td></td>';
1342  print '<td class="liste_titre"></td>';
1343  print '<td class="liste_titre right" colspan="2">';
1344  if ($filterfound)
1345  {
1346  $searchpicto = $form->showFilterAndCheckAddButtons(0);
1347  print $searchpicto;
1348  }
1349  print '</td>';
1350  print '</tr>';
1351 
1352  // Title of lines
1353  print '<tr class="liste_titre">';
1354  foreach ($fieldlist as $field => $value)
1355  {
1356  if ($fieldlist[$field] == 'entity') continue;
1357 
1358  if (in_array($value, array('label', 'libelle', 'libelle_facture')) && empty($tabhelp[$id][$value])) {
1359  $tabhelp[$id][$value] = $langs->trans('LabelUsedByDefault');
1360  }
1361 
1362  // Determines the name of the field in relation to the possible names
1363  // in data dictionaries
1364  $showfield = 1; // By defaut
1365  $cssprefix = '';
1366  $sortable = 1;
1367  $valuetoshow = ucfirst($fieldlist[$field]); // By defaut
1368  $valuetoshow = $langs->trans($valuetoshow); // try to translate
1369 
1370  // Special cases
1371  if ($fieldlist[$field] == 'source') { $valuetoshow = $langs->trans("Contact"); }
1372  if ($fieldlist[$field] == 'price') { $valuetoshow = $langs->trans("PriceUHT"); }
1373  if ($fieldlist[$field] == 'taux') {
1374  if ($tabname[$id] != MAIN_DB_PREFIX."c_revenuestamp") $valuetoshow = $langs->trans("Rate");
1375  else $valuetoshow = $langs->trans("Amount");
1376  $cssprefix = 'center ';
1377  }
1378  if ($fieldlist[$field] == 'localtax1_type') { $valuetoshow = $langs->trans("UseLocalTax")." 2"; $cssprefix = "center "; $sortable = 0; }
1379  if ($fieldlist[$field] == 'localtax1') { $valuetoshow = $langs->trans("Rate")." 2"; $cssprefix = "center "; $sortable = 0; }
1380  if ($fieldlist[$field] == 'localtax2_type') { $valuetoshow = $langs->trans("UseLocalTax")." 3"; $cssprefix = "center "; $sortable = 0; }
1381  if ($fieldlist[$field] == 'localtax2') { $valuetoshow = $langs->trans("Rate")." 3"; $cssprefix = "center "; $sortable = 0; }
1382  if ($fieldlist[$field] == 'organization') { $valuetoshow = $langs->trans("Organization"); }
1383  if ($fieldlist[$field] == 'lang') { $valuetoshow = $langs->trans("Language"); }
1384  if ($fieldlist[$field] == 'type') { $valuetoshow = $langs->trans("Type"); }
1385  if ($fieldlist[$field] == 'code') { $valuetoshow = $langs->trans("Code"); }
1386  if ($fieldlist[$field] == 'pos') { $cssprefix = 'right '; $valuetoshow = $langs->trans("Position"); }
1387  if ($fieldlist[$field] == 'position') { $cssprefix = 'right '; $valuetoshow = $langs->trans("Position"); }
1388  if ($fieldlist[$field] == 'libelle' || $fieldlist[$field] == 'label') { $valuetoshow = $langs->trans("Label"); }
1389  if ($fieldlist[$field] == 'libelle_facture') { $valuetoshow = $langs->trans("LabelOnDocuments"); }
1390  if ($fieldlist[$field] == 'country') { $valuetoshow = $langs->trans("Country"); }
1391  if ($fieldlist[$field] == 'recuperableonly') { $valuetoshow = $langs->trans("NPR"); $cssprefix = "center "; }
1392  if ($fieldlist[$field] == 'nbjour') { $valuetoshow = $langs->trans("NbOfDays"); }
1393  if ($fieldlist[$field] == 'type_cdr') { $valuetoshow = $langs->trans("AtEndOfMonth"); $cssprefix = "center "; }
1394  if ($fieldlist[$field] == 'decalage') { $valuetoshow = $langs->trans("Offset"); }
1395  if ($fieldlist[$field] == 'width' || $fieldlist[$field] == 'nx') { $valuetoshow = $langs->trans("Width"); }
1396  if ($fieldlist[$field] == 'height' || $fieldlist[$field] == 'ny') { $valuetoshow = $langs->trans("Height"); }
1397  if ($fieldlist[$field] == 'unit' || $fieldlist[$field] == 'metric') { $valuetoshow = $langs->trans("MeasuringUnit"); }
1398  if ($fieldlist[$field] == 'accountancy_code') { $valuetoshow = $langs->trans("AccountancyCode"); }
1399  if ($fieldlist[$field] == 'accountancy_code_sell') { $valuetoshow = $langs->trans("AccountancyCodeSell"); $sortable = 0; }
1400  if ($fieldlist[$field] == 'accountancy_code_buy') { $valuetoshow = $langs->trans("AccountancyCodeBuy"); $sortable = 0; }
1401  if ($fieldlist[$field] == 'fk_pcg_version') { $valuetoshow = $langs->trans("Pcg_version"); }
1402  if ($fieldlist[$field] == 'account_parent') { $valuetoshow = $langs->trans("Accountsparent"); }
1403  if ($fieldlist[$field] == 'pcg_type') { $valuetoshow = $langs->trans("Pcg_type"); }
1404  if ($fieldlist[$field] == 'pcg_subtype') { $valuetoshow = $langs->trans("Pcg_subtype"); }
1405  if ($fieldlist[$field] == 'sortorder') { $valuetoshow = $langs->trans("SortOrder"); }
1406  if ($fieldlist[$field] == 'short_label') { $valuetoshow = $langs->trans("ShortLabel"); }
1407  if ($fieldlist[$field] == 'range_account') { $valuetoshow = $langs->trans("Range"); }
1408  if ($fieldlist[$field] == 'sens') { $valuetoshow = $langs->trans("Sens"); }
1409  if ($fieldlist[$field] == 'category_type') { $valuetoshow = $langs->trans("Calculated"); }
1410  if ($fieldlist[$field] == 'formula') { $valuetoshow = $langs->trans("Formula"); }
1411  if ($fieldlist[$field] == 'paper_size') { $valuetoshow = $langs->trans("PaperSize"); }
1412  if ($fieldlist[$field] == 'orientation') { $valuetoshow = $langs->trans("Orientation"); }
1413  if ($fieldlist[$field] == 'leftmargin') { $valuetoshow = $langs->trans("LeftMargin"); }
1414  if ($fieldlist[$field] == 'topmargin') { $valuetoshow = $langs->trans("TopMargin"); }
1415  if ($fieldlist[$field] == 'spacex') { $valuetoshow = $langs->trans("SpaceX"); }
1416  if ($fieldlist[$field] == 'spacey') { $valuetoshow = $langs->trans("SpaceY"); }
1417  if ($fieldlist[$field] == 'font_size') { $valuetoshow = $langs->trans("FontSize"); }
1418  if ($fieldlist[$field] == 'custom_x') { $valuetoshow = $langs->trans("CustomX"); }
1419  if ($fieldlist[$field] == 'custom_y') { $valuetoshow = $langs->trans("CustomY"); }
1420  if ($fieldlist[$field] == 'percent') { $valuetoshow = $langs->trans("Percentage"); }
1421  if ($fieldlist[$field] == 'affect') { $valuetoshow = $langs->trans("WithCounter"); }
1422  if ($fieldlist[$field] == 'delay') { $valuetoshow = $langs->trans("NoticePeriod"); }
1423  if ($fieldlist[$field] == 'newbymonth') { $valuetoshow = $langs->trans("NewByMonth"); }
1424  if ($fieldlist[$field] == 'fk_tva') { $valuetoshow = $langs->trans("VAT"); }
1425  if ($fieldlist[$field] == 'range_ik') { $valuetoshow = $langs->trans("RangeIk"); }
1426  if ($fieldlist[$field] == 'fk_c_exp_tax_cat') { $valuetoshow = $langs->trans("CarCategory"); }
1427  if ($fieldlist[$field] == 'revenuestamp_type') { $valuetoshow = $langs->trans('TypeOfRevenueStamp'); }
1428  if ($fieldlist[$field] == 'use_default') { $valuetoshow = $langs->trans('Default'); $cssprefix = 'center '; }
1429  if ($fieldlist[$field] == 'unit_type') { $valuetoshow = $langs->trans('TypeOfUnit'); }
1430 
1431  if ($fieldlist[$field] == 'region_id' || $fieldlist[$field] == 'country_id') { $showfield = 0; }
1432 
1433  // Show field title
1434  if ($showfield)
1435  {
1436  if (!empty($tabhelp[$id][$value]) && preg_match('/^http(s*):/i', $tabhelp[$id][$value])) $newvaluetoshow = '<a href="'.$tabhelp[$id][$value].'" target="_blank">'.$valuetoshow.' '.img_help(1, $valuetoshow).'</a>';
1437  elseif (!empty($tabhelp[$id][$value])) $newvaluetoshow = $form->textwithpicto($valuetoshow, $tabhelp[$id][$value]);
1438  else $newvaluetoshow = $valuetoshow;
1439 
1440  print getTitleFieldOfList($newvaluetoshow, 0, $_SERVER["PHP_SELF"], ($sortable ? $fieldlist[$field] : ''), ($page ? 'page='.$page.'&' : ''), $param, '', $sortfield, $sortorder, $cssprefix);
1441  }
1442  }
1443  // Favorite - Only activated on country dictionary
1444  if ($id == 4) print getTitleFieldOfList($langs->trans("Favorite"), 0, $_SERVER["PHP_SELF"], "favorite", ($page ? 'page='.$page.'&' : ''), $param, 'align="center"', $sortfield, $sortorder);
1445 
1446  print getTitleFieldOfList($langs->trans("Status"), 0, $_SERVER["PHP_SELF"], "active", ($page ? 'page='.$page.'&' : ''), $param, 'align="center"', $sortfield, $sortorder);
1449  print '</tr>';
1450 
1451  if ($num)
1452  {
1453  // Lines with values
1454  while ($i < $num)
1455  {
1456  $obj = $db->fetch_object($resql);
1457  //print_r($obj);
1458  print '<tr class="oddeven" id="rowid-'.$obj->rowid.'">';
1459  if ($action == 'edit' && ($rowid == (!empty($obj->rowid) ? $obj->rowid : $obj->code)))
1460  {
1461  $tmpaction = 'edit';
1462  $parameters = array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]);
1463  $reshook = $hookmanager->executeHooks('editDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
1464  $error = $hookmanager->error; $errors = $hookmanager->errors;
1465 
1466  // Show fields
1467  if (empty($reshook)) {
1468  $withentity = fieldList($fieldlist, $obj, $tabname[$id], 'edit');
1469  }
1470 
1471  print '<td colspan="3" class="center">';
1472  print '<div name="'.(!empty($obj->rowid) ? $obj->rowid : $obj->code).'"></div>';
1473  print '<input type="hidden" name="page" value="'.dol_escape_htmltag($page).'">';
1474  print '<input type="hidden" name="rowid" value="'.dol_escape_htmltag($rowid).'">';
1475  if (!is_null($withentity))
1476  print '<input type="hidden" name="entity" value="'.$withentity.'">';
1477  print '<input type="submit" class="button" name="actionmodify" value="'.$langs->trans("Modify").'">';
1478  print '<input type="submit" class="button button-cancel" name="actioncancel" value="'.$langs->trans("Cancel").'">';
1479  print '</td>';
1480  } else {
1481  $tmpaction = 'view';
1482  $parameters = array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]);
1483  $reshook = $hookmanager->executeHooks('viewDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
1484 
1485  $error = $hookmanager->error; $errors = $hookmanager->errors;
1486 
1487  if (empty($reshook))
1488  {
1489  $withentity = null;
1490 
1491  foreach ($fieldlist as $field => $value)
1492  {
1493  //var_dump($fieldlist);
1494  $class = '';
1495  $showfield = 1;
1496  $valuetoshow = $obj->{$fieldlist[$field]};
1497 
1498  if ($fieldlist[$field] == 'entity') {
1499  $withentity = $valuetoshow;
1500  continue;
1501  }
1502 
1503  if ($value == 'element') {
1504  $valuetoshow = isset($elementList[$valuetoshow]) ? $elementList[$valuetoshow] : $valuetoshow;
1505  } elseif ($value == 'source') {
1506  $valuetoshow = isset($sourceList[$valuetoshow]) ? $sourceList[$valuetoshow] : $valuetoshow;
1507  } elseif ($valuetoshow == 'all') {
1508  $valuetoshow = $langs->trans('All');
1509  } elseif ($fieldlist[$field] == 'country') {
1510  if (empty($obj->country_code))
1511  {
1512  $valuetoshow = '-';
1513  } else {
1514  $key = $langs->trans("Country".strtoupper($obj->country_code));
1515  $valuetoshow = ($key != "Country".strtoupper($obj->country_code) ? $obj->country_code." - ".$key : $obj->country);
1516  }
1517  } elseif ($fieldlist[$field] == 'recuperableonly' || $fieldlist[$field] == 'deductible' || $fieldlist[$field] == 'category_type') {
1518  $valuetoshow = yn($valuetoshow);
1519  $class = "center";
1520  } elseif ($fieldlist[$field] == 'type_cdr') {
1521  if (empty($valuetoshow)) $valuetoshow = $langs->trans('None');
1522  elseif ($valuetoshow == 1) $valuetoshow = $langs->trans('AtEndOfMonth');
1523  elseif ($valuetoshow == 2) $valuetoshow = $langs->trans('CurrentNext');
1524  $class = "center";
1525  } elseif ($fieldlist[$field] == 'price' || preg_match('/^amount/i', $fieldlist[$field])) {
1526  $valuetoshow = price($valuetoshow);
1527  }
1528  if ($value == 'private')
1529  {
1530  $valuetoshow = yn($elementList[$valuetoshow]);
1531  } elseif ($fieldlist[$field] == 'libelle_facture') {
1532  $langs->load("bills");
1533  $key = $langs->trans("PaymentCondition".strtoupper($obj->code));
1534  $valuetoshow = ($obj->code && $key != "PaymentCondition".strtoupper($obj->code) ? $key : $obj->{$fieldlist[$field]});
1535  $valuetoshow = nl2br($valuetoshow);
1536  } elseif ($fieldlist[$field] == 'label' && $tabname[$id] == MAIN_DB_PREFIX.'c_country') {
1537  $key = $langs->trans("Country".strtoupper($obj->code));
1538  $valuetoshow = ($obj->code && $key != "Country".strtoupper($obj->code) ? $key : $obj->{$fieldlist[$field]});
1539  } elseif ($fieldlist[$field] == 'label' && $tabname[$id] == MAIN_DB_PREFIX.'c_availability') {
1540  $langs->load("propal");
1541  $key = $langs->trans("AvailabilityType".strtoupper($obj->code));
1542  $valuetoshow = ($obj->code && $key != "AvailabilityType".strtoupper($obj->code) ? $key : $obj->{$fieldlist[$field]});
1543  } elseif ($fieldlist[$field] == 'libelle' && $tabname[$id] == MAIN_DB_PREFIX.'c_actioncomm') {
1544  $key = $langs->trans("Action".strtoupper($obj->code));
1545  $valuetoshow = ($obj->code && $key != "Action".strtoupper($obj->code) ? $key : $obj->{$fieldlist[$field]});
1546  } elseif (!empty($obj->code_iso) && $fieldlist[$field] == 'label' && $tabname[$id] == MAIN_DB_PREFIX.'c_currencies') {
1547  $key = $langs->trans("Currency".strtoupper($obj->code_iso));
1548  $valuetoshow = ($obj->code_iso && $key != "Currency".strtoupper($obj->code_iso) ? $key : $obj->{$fieldlist[$field]});
1549  } elseif ($fieldlist[$field] == 'libelle' && $tabname[$id] == MAIN_DB_PREFIX.'c_typent') {
1550  $key = $langs->trans(strtoupper($obj->code));
1551  $valuetoshow = ($key != strtoupper($obj->code) ? $key : $obj->{$fieldlist[$field]});
1552  } elseif ($fieldlist[$field] == 'libelle' && $tabname[$id] == MAIN_DB_PREFIX.'c_prospectlevel') {
1553  $key = $langs->trans(strtoupper($obj->code));
1554  $valuetoshow = ($key != strtoupper($obj->code) ? $key : $obj->{$fieldlist[$field]});
1555  } elseif ($fieldlist[$field] == 'label' && $tabname[$id] == MAIN_DB_PREFIX.'c_civility') {
1556  $key = $langs->trans("Civility".strtoupper($obj->code));
1557  $valuetoshow = ($obj->code && $key != "Civility".strtoupper($obj->code) ? $key : $obj->{$fieldlist[$field]});
1558  } elseif ($fieldlist[$field] == 'libelle' && $tabname[$id] == MAIN_DB_PREFIX.'c_type_contact') {
1559  $langs->load('agenda');
1560  $key = $langs->trans("TypeContact_".$obj->element."_".$obj->source."_".strtoupper($obj->code));
1561  $valuetoshow = ($obj->code && $key != "TypeContact_".$obj->element."_".$obj->source."_".strtoupper($obj->code) ? $key : $obj->{$fieldlist[$field]});
1562  } elseif ($fieldlist[$field] == 'libelle' && $tabname[$id] == MAIN_DB_PREFIX.'c_payment_term') {
1563  $langs->load("bills");
1564  $key = $langs->trans("PaymentConditionShort".strtoupper($obj->code));
1565  $valuetoshow = ($obj->code && $key != "PaymentConditionShort".strtoupper($obj->code) ? $key : $obj->{$fieldlist[$field]});
1566  } elseif ($fieldlist[$field] == 'libelle' && $tabname[$id] == MAIN_DB_PREFIX.'c_paiement') {
1567  $langs->load("bills");
1568  $key = $langs->trans("PaymentType".strtoupper($obj->code));
1569  $valuetoshow = ($obj->code && $key != "PaymentType".strtoupper($obj->code) ? $key : $obj->{$fieldlist[$field]});
1570  } elseif ($fieldlist[$field] == 'type' && $tabname[$id] == MAIN_DB_PREFIX.'c_paiement') {
1571  $payment_type_list = array(0=>$langs->trans('PaymentTypeCustomer'), 1=>$langs->trans('PaymentTypeSupplier'), 2=>$langs->trans('PaymentTypeBoth'));
1572  $valuetoshow = $payment_type_list[$valuetoshow];
1573  } elseif ($fieldlist[$field] == 'label' && $tabname[$id] == MAIN_DB_PREFIX.'c_input_reason') {
1574  $key = $langs->trans("DemandReasonType".strtoupper($obj->code));
1575  $valuetoshow = ($obj->code && $key != "DemandReasonType".strtoupper($obj->code) ? $key : $obj->{$fieldlist[$field]});
1576  } elseif ($fieldlist[$field] == 'libelle' && $tabname[$id] == MAIN_DB_PREFIX.'c_input_method') {
1577  $langs->load("orders");
1578  $key = $langs->trans($obj->code);
1579  $valuetoshow = ($obj->code && $key != $obj->code) ? $key : $obj->{$fieldlist[$field]};
1580  } elseif ($fieldlist[$field] == 'libelle' && $tabname[$id] == MAIN_DB_PREFIX.'c_shipment_mode') {
1581  $langs->load("sendings");
1582  $key = $langs->trans("SendingMethod".strtoupper($obj->code));
1583  $valuetoshow = ($obj->code && $key != "SendingMethod".strtoupper($obj->code) ? $key : $obj->{$fieldlist[$field]});
1584  } elseif ($fieldlist[$field] == 'libelle' && $tabname[$id] == MAIN_DB_PREFIX.'c_paper_format')
1585  {
1586  $key = $langs->trans('PaperFormat'.strtoupper($obj->code));
1587  $valuetoshow = ($obj->code && $key != 'PaperFormat'.strtoupper($obj->code) ? $key : $obj->{$fieldlist[$field]});
1588  } elseif ($fieldlist[$field] == 'label' && $tabname[$id] == MAIN_DB_PREFIX.'c_type_fees')
1589  {
1590  $langs->load('trips');
1591  $key = $langs->trans(strtoupper($obj->code));
1592  $valuetoshow = ($obj->code && $key != strtoupper($obj->code) ? $key : $obj->{$fieldlist[$field]});
1593  } elseif ($fieldlist[$field] == 'region_id' || $fieldlist[$field] == 'country_id') {
1594  $showfield = 0;
1595  } elseif ($fieldlist[$field] == 'unicode') {
1596  $valuetoshow = $langs->getCurrencySymbol($obj->code, 1);
1597  } elseif ($fieldlist[$field] == 'label' && $tabname[$_GET["id"]] == MAIN_DB_PREFIX.'c_units') {
1598  $langs->load("products");
1599  $valuetoshow = $langs->trans($obj->{$fieldlist[$field]});
1600  } elseif ($fieldlist[$field] == 'short_label' && $tabname[$_GET["id"]] == MAIN_DB_PREFIX.'c_units') {
1601  $langs->load("products");
1602  $valuetoshow = $langs->trans($obj->{$fieldlist[$field]});
1603  } elseif (($fieldlist[$field] == 'unit') && ($tabname[$id] == MAIN_DB_PREFIX.'c_paper_format'))
1604  {
1605  $key = $langs->trans('SizeUnit'.strtolower($obj->unit));
1606  $valuetoshow = ($obj->code && $key != 'SizeUnit'.strtolower($obj->unit) ? $key : $obj->{$fieldlist[$field]});
1607  } elseif ($fieldlist[$field] == 'localtax1' || $fieldlist[$field] == 'localtax2') {
1608  $class = "center";
1609  } elseif ($fieldlist[$field] == 'localtax1_type') {
1610  if ($obj->localtax1 != 0)
1611  $valuetoshow = $localtax_typeList[$valuetoshow];
1612  else $valuetoshow = '';
1613  $class = "center";
1614  } elseif ($fieldlist[$field] == 'localtax2_type') {
1615  if ($obj->localtax2 != 0)
1616  $valuetoshow = $localtax_typeList[$valuetoshow];
1617  else $valuetoshow = '';
1618  $class = "center";
1619  } elseif ($fieldlist[$field] == 'taux') {
1620  $valuetoshow = price($valuetoshow, 0, $langs, 0, 0);
1621  $class = "center";
1622  } elseif (in_array($fieldlist[$field], array('recuperableonly'))) {
1623  $class = "center";
1624  } elseif ($fieldlist[$field] == 'accountancy_code' || $fieldlist[$field] == 'accountancy_code_sell' || $fieldlist[$field] == 'accountancy_code_buy') {
1625  $valuetoshow = length_accountg($valuetoshow);
1626  } elseif ($fieldlist[$field] == 'fk_tva')
1627  {
1628  foreach ($form->cache_vatrates as $key => $Tab)
1629  {
1630  if ($form->cache_vatrates[$key]['rowid'] == $valuetoshow)
1631  {
1632  $valuetoshow = $form->cache_vatrates[$key]['libtva'];
1633  break;
1634  }
1635  }
1636  } elseif ($fieldlist[$field] == 'fk_c_exp_tax_cat')
1637  {
1638  $valuetoshow = getDictvalue(MAIN_DB_PREFIX.'c_exp_tax_cat', 'label', $valuetoshow);
1639  $valuetoshow = $langs->trans($valuetoshow);
1640  } elseif ($tabname[$id] == MAIN_DB_PREFIX.'c_exp_tax_cat')
1641  {
1642  $valuetoshow = $langs->trans($valuetoshow);
1643  } elseif ($fieldlist[$field] == 'label' && $tabname[$id] == MAIN_DB_PREFIX.'c_units')
1644  {
1645  $langs->load('other');
1646  $key = $langs->trans($obj->label);
1647  $valuetoshow = ($obj->label && $key != strtoupper($obj->label) ? $key : $obj->{$fieldlist[$field]});
1648  } elseif ($fieldlist[$field] == 'code' && $id == 3) {
1649  $valuetoshow = $obj->state_code;
1650  } elseif ($fieldlist[$field] == 'label' && $tabname[$id] == MAIN_DB_PREFIX.'c_product_nature') {
1651  $langs->load("products");
1652  $valuetoshow = $langs->trans($obj->{$fieldlist[$field]});
1653  }
1654  $class .= ($class ? ' ' : '').'tddict';
1655  if ($fieldlist[$field] == 'note' && $id == 10) $class .= ' tdoverflowmax200';
1656  if ($fieldlist[$field] == 'tracking') $class .= ' tdoverflowauto';
1657  if ($fieldlist[$field] == 'position') $class .= ' right';
1658  if ($fieldlist[$field] == 'localtax1_type') $class .= ' nowrap';
1659  if ($fieldlist[$field] == 'localtax2_type') $class .= ' nowrap';
1660  if ($fieldlist[$field] == 'pos') $class .= ' right';
1661  if ($fieldlist[$field] == 'use_default') $class .= ' center';
1662  // Show value for field
1663  if ($showfield) print '<!-- '.$fieldlist[$field].' --><td class="'.$class.'">'.$valuetoshow.'</td>';
1664  }
1665  }
1666 
1667  // Can an entry be erased or disabled ?
1668  // all true by default
1669  $iserasable = 1;
1670  $canbedisabled = 1;
1671  $canbemodified = 1;
1672  if (isset($obj->code) && $id != 10 && $id != 42)
1673  {
1674  if (($obj->code == '0' || $obj->code == '' || preg_match('/unknown/i', $obj->code))) { $iserasable = 0; $canbedisabled = 0; } elseif ($obj->code == 'RECEP') { $iserasable = 0; $canbedisabled = 0; } elseif ($obj->code == 'EF0') { $iserasable = 0; $canbedisabled = 0; }
1675  }
1676  if ($id == 25 && in_array($obj->code, array('banner', 'blogpost', 'other', 'page')))
1677  {
1678  $iserasable = 0; $canbedisabled = 0;
1679  if (in_array($obj->code, array('banner'))) $canbedisabled = 1;
1680  }
1681  if (isset($obj->type) && in_array($obj->type, array('system', 'systemauto'))) { $iserasable = 0; }
1682  if (in_array($obj->code, array('AC_OTH', 'AC_OTH_AUTO')) || in_array($obj->type, array('systemauto'))) { $canbedisabled = 0; $canbedisabled = 0; }
1683  $canbemodified = $iserasable;
1684 
1685  if ($obj->code == 'RECEP') $canbemodified = 1;
1686  if ($tabname[$id] == MAIN_DB_PREFIX."c_actioncomm") $canbemodified = 1;
1687 
1688  // Build Url. The table is id=, the id of line is rowid=
1689  $rowidcol = $tabrowid[$id];
1690  // If rowidcol not defined
1691  if (empty($rowidcol) || in_array($id, array(6, 7, 8, 13, 17, 19, 27, 32))) $rowidcol = 'rowid';
1692  $url = $_SERVER["PHP_SELF"].'?'.($page ? 'page='.$page.'&' : '').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.((!empty($obj->{$rowidcol}) || $obj->{$rowidcol} == '0') ? $obj->{$rowidcol}:(!empty($obj->code) ?urlencode($obj->code) : '')).'&code='.(!empty($obj->code) ?urlencode($obj->code) : '');
1693  if (!empty($param)) $url .= '&'.$param;
1694  if (!is_null($withentity)) $url .= '&entity='.$withentity;
1695  $url .= '&';
1696 
1697  // Favorite
1698  // Only activated on country dictionary
1699  if ($id == 4)
1700  {
1701  print '<td class="nowrap center">';
1702  if ($iserasable) print '<a class="reposition" href="'.$url.'action='.$acts[$obj->favorite].'_favorite">'.$actl[$obj->favorite].'</a>';
1703  else print $langs->trans("AlwaysActive");
1704  print '</td>';
1705  }
1706 
1707  // Active
1708  print '<td class="nowrap center">';
1709  if ($canbedisabled) print '<a class="reposition" href="'.$url.'action='.$acts[$obj->active].'">'.$actl[$obj->active].'</a>';
1710  else {
1711  if (in_array($obj->code, array('AC_OTH', 'AC_OTH_AUTO'))) print $langs->trans("AlwaysActive");
1712  elseif (isset($obj->type) && in_array($obj->type, array('systemauto')) && empty($obj->active)) print $langs->trans("Deprecated");
1713  elseif (isset($obj->type) && in_array($obj->type, array('system')) && !empty($obj->active) && $obj->code != 'AC_OTH') print $langs->trans("UsedOnlyWithTypeOption");
1714  else print $langs->trans("AlwaysActive");
1715  }
1716  print "</td>";
1717 
1718  // Modify link
1719  if ($canbemodified) print '<td align="center"><a class="reposition editfielda" href="'.$url.'action=edit&token='.newToken().'">'.img_edit().'</a></td>';
1720  else print '<td>&nbsp;</td>';
1721 
1722  // Delete link
1723  if ($iserasable)
1724  {
1725  print '<td class="center">';
1726  if ($user->admin) print '<a href="'.$url.'action=delete&token='.newToken().'">'.img_delete().'</a>';
1727  //else print '<a href="#">'.img_delete().'</a>'; // Some dictionary can be edited by other profile than admin
1728  print '</td>';
1729  } else print '<td>&nbsp;</td>';
1730 
1731  print "</tr>\n";
1732  }
1733  $i++;
1734  }
1735  }
1736 
1737  print '</table>';
1738  print '</div>';
1739  } else {
1740  dol_print_error($db);
1741  }
1742 
1743  print '</form>';
1744 } else {
1745  /*
1746  * Show list of dictionary to show
1747  */
1748 
1749  $lastlineisempty = false;
1750 
1751  print '<div class="div-table-responsive-no-min">';
1752  print '<table class="noborder centpercent">';
1753  print '<tr class="liste_titre">';
1754  print '<td colspan="2">'.$langs->trans("Dictionary").'</td>';
1755  print '<td>'.$langs->trans("Table").'</td>';
1756  print '</tr>';
1757 
1758  $showemptyline = '';
1759  foreach ($taborder as $i)
1760  {
1761  if (isset($tabname[$i]) && empty($tabcond[$i])) continue;
1762 
1763  if ($i)
1764  {
1765  if ($showemptyline)
1766  {
1767  print '<tr class="oddeven"><td width="50%">&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>';
1768  $showemptyline = 0;
1769  }
1770 
1771 
1772  $value = $tabname[$i];
1773  print '<tr class="oddeven"><td width="50%">';
1774  if (!empty($tabcond[$i]))
1775  {
1776  print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$i.'">'.$langs->trans($tablib[$i]).'</a>';
1777  } else {
1778  print $langs->trans($tablib[$i]);
1779  }
1780  print '</td>';
1781  print '<td>';
1782  /*if (empty($tabcond[$i]))
1783  {
1784  print info_admin($langs->trans("DictionaryDisabledSinceNoModuleNeedIt"),1);
1785  }*/
1786  print '</td>';
1787  print '<td>'.$tabname[$i].'</td></tr>';
1788  $lastlineisempty = false;
1789  } else {
1790  if (!$lastlineisempty)
1791  {
1792  $showemptyline = 1;
1793  $lastlineisempty = true;
1794  }
1795  }
1796  }
1797  print '</table>';
1798  print '</div>';
1799 }
1800 
1801 print '<br>';
1802 
1803 // End of page
1804 llxFooter();
1805 $db->close();
1806 
1807 
1817 function fieldList($fieldlist, $obj = '', $tabname = '', $context = '')
1818 {
1819  global $conf, $langs, $db, $mysoc;
1820  global $form;
1821  global $region_id;
1822  global $elementList, $sourceList, $localtax_typeList;
1823 
1824  $formadmin = new FormAdmin($db);
1825  $formcompany = new FormCompany($db);
1826  $formaccounting = new FormAccounting($db);
1827 
1828  $withentity = '';
1829 
1830  foreach ($fieldlist as $field => $value)
1831  {
1832  if ($fieldlist[$field] == 'entity') {
1833  $withentity = $obj->{$fieldlist[$field]};
1834  continue;
1835  }
1836 
1837  if (in_array($fieldlist[$field], array('code', 'libelle', 'type')) && $tabname == MAIN_DB_PREFIX."c_actioncomm" && in_array($obj->type, array('system', 'systemauto')))
1838  {
1839  $hidden = (!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:'');
1840  print '<td>';
1841  print '<input type="hidden" name="'.$fieldlist[$field].'" value="'.$hidden.'">';
1842  print $langs->trans($hidden);
1843  print '</td>';
1844  } elseif ($fieldlist[$field] == 'country')
1845  {
1846  if (in_array('region_id', $fieldlist))
1847  {
1848  print '<td>';
1849  print '</td>';
1850  continue;
1851  } // For state page, we do not show the country input (we link to region, not country)
1852  print '<td>';
1853  $fieldname = 'country';
1854  print $form->select_country((!empty($obj->country_code) ? $obj->country_code : (!empty($obj->country) ? $obj->country : '')), $fieldname, '', 28, 'maxwidth150 maxwidthonsmartphone');
1855  print '</td>';
1856  } elseif ($fieldlist[$field] == 'country_id')
1857  {
1858  if (!in_array('country', $fieldlist)) // If there is already a field country, we don't show country_id (avoid duplicate)
1859  {
1860  $country_id = (!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]} : 0);
1861  print '<td class="tdoverflowmax100">';
1862  print '<input type="hidden" name="'.$fieldlist[$field].'" value="'.$country_id.'">';
1863  print '</td>';
1864  }
1865  } elseif ($fieldlist[$field] == 'region')
1866  {
1867  print '<td>';
1868  $formcompany->select_region($region_id, 'region');
1869  print '</td>';
1870  } elseif ($fieldlist[$field] == 'region_id')
1871  {
1872  $region_id = (!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:0);
1873  print '<td>';
1874  print '<input type="hidden" name="'.$fieldlist[$field].'" value="'.$region_id.'">';
1875  print '</td>';
1876  } elseif ($fieldlist[$field] == 'lang')
1877  {
1878  print '<td>';
1879  print $formadmin->select_language($conf->global->MAIN_LANG_DEFAULT, 'lang');
1880  print '</td>';
1881  }
1882  // The type of the element (for contact types)
1883  elseif ($fieldlist[$field] == 'element')
1884  {
1885  print '<td>';
1886  print $form->selectarray('element', $elementList, (!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:''));
1887  print '</td>';
1888  }
1889  // The source of the element (for contact types)
1890  elseif ($fieldlist[$field] == 'source')
1891  {
1892  print '<td>';
1893  print $form->selectarray('source', $sourceList, (!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:''));
1894  print '</td>';
1895  } elseif ($fieldlist[$field] == 'private')
1896  {
1897  print '<td>';
1898  print $form->selectyesno("private", (!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:''));
1899  print '</td>';
1900  } elseif ($fieldlist[$field] == 'type' && $tabname == MAIN_DB_PREFIX."c_actioncomm")
1901  {
1902  $type = (!empty($obj->type) ? $obj->type : 'user'); // Check if type is different of 'user' (external module)
1903  print '<td>';
1904  print $type.'<input type="hidden" name="type" value="'.$type.'">';
1905  print '</td>';
1906  } elseif ($fieldlist[$field] == 'type' && $tabname == MAIN_DB_PREFIX.'c_paiement')
1907  {
1908  print '<td>';
1909  $select_list = array(0=>$langs->trans('PaymentTypeCustomer'), 1=>$langs->trans('PaymentTypeSupplier'), 2=>$langs->trans('PaymentTypeBoth'));
1910  print $form->selectarray($fieldlist[$field], $select_list, (!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:'2'));
1911  print '</td>';
1912  } elseif ($fieldlist[$field] == 'recuperableonly' || $fieldlist[$field] == 'type_cdr' || $fieldlist[$field] == 'deductible' || $fieldlist[$field] == 'category_type') {
1913  if ($fieldlist[$field] == 'type_cdr') print '<td class="center">';
1914  else print '<td>';
1915  if ($fieldlist[$field] == 'type_cdr') {
1916  print $form->selectarray($fieldlist[$field], array(0=>$langs->trans('None'), 1=>$langs->trans('AtEndOfMonth'), 2=>$langs->trans('CurrentNext')), (!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:''));
1917  } else {
1918  print $form->selectyesno($fieldlist[$field], (!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:''), 1);
1919  }
1920  print '</td>';
1921  } elseif (in_array($fieldlist[$field], array('nbjour', 'decalage', 'taux', 'localtax1', 'localtax2'))) {
1922  $class = "left";
1923  if (in_array($fieldlist[$field], array('taux', 'localtax1', 'localtax2'))) $class = "center"; // Fields aligned on right
1924  print '<td class="'.$class.'">';
1925  print '<input type="text" class="flat" value="'.(isset($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]} : '').'" size="3" name="'.$fieldlist[$field].'">';
1926  print '</td>';
1927  } elseif (in_array($fieldlist[$field], array('libelle_facture'))) {
1928  print '<td>';
1929  $transfound = 0;
1930  $transkey = '';
1931  // Special case for labels
1932  if ($tabname == MAIN_DB_PREFIX.'c_payment_term')
1933  {
1934  $langs->load("bills");
1935  $transkey = "PaymentCondition".strtoupper($obj->code);
1936  if ($langs->trans($transkey) != $transkey)
1937  {
1938  $transfound = 1;
1939  print $form->textwithpicto($langs->trans($transkey), $langs->trans("GoIntoTranslationMenuToChangeThis"));
1940  }
1941  }
1942  if (!$transfound)
1943  {
1944  print '<textarea cols="30" rows="'.ROWS_2.'" class="flat" name="'.$fieldlist[$field].'">'.(!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:'').'</textarea>';
1945  } else {
1946  print '<input type="hidden" name="'.$fieldlist[$field].'" value="'.$transkey.'">';
1947  }
1948  print '</td>';
1949  } elseif ($fieldlist[$field] == 'price' || preg_match('/^amount/i', $fieldlist[$field])) {
1950  print '<td><input type="text" class="flat minwidth75" value="'.price((!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:'')).'" name="'.$fieldlist[$field].'"></td>';
1951  } elseif ($fieldlist[$field] == 'code' && isset($obj->{$fieldlist[$field]})) {
1952  print '<td><input type="text" class="flat minwidth75 maxwidth100" value="'.(!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:'').'" name="'.$fieldlist[$field].'"></td>';
1953  } elseif ($fieldlist[$field] == 'unit') {
1954  print '<td>';
1955  $units = array(
1956  'mm' => $langs->trans('SizeUnitmm'),
1957  'cm' => $langs->trans('SizeUnitcm'),
1958  'point' => $langs->trans('SizeUnitpoint'),
1959  'inch' => $langs->trans('SizeUnitinch')
1960  );
1961  print $form->selectarray('unit', $units, (!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:''), 0, 0, 0);
1962  print '</td>';
1963  }
1964  // Le type de taxe locale
1965  elseif ($fieldlist[$field] == 'localtax1_type' || $fieldlist[$field] == 'localtax2_type')
1966  {
1967  print '<td class="center">';
1968  print $form->selectarray($fieldlist[$field], $localtax_typeList, (!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:''));
1969  print '</td>';
1970  } elseif ($fieldlist[$field] == 'accountancy_code' || $fieldlist[$field] == 'accountancy_code_sell' || $fieldlist[$field] == 'accountancy_code_buy')
1971  {
1972  print '<td>';
1973  if (!empty($conf->accounting->enabled))
1974  {
1975  $fieldname = $fieldlist[$field];
1976  $accountancy_account = (!empty($obj->$fieldname) ? $obj->$fieldname : 0);
1977  print $formaccounting->select_account($accountancy_account, '.'.$fieldlist[$field], 1, '', 1, 1, 'maxwidth200 maxwidthonsmartphone');
1978  } else {
1979  $fieldname = $fieldlist[$field];
1980  print '<input type="text" size="10" class="flat" value="'.(isset($obj->$fieldname) ? $obj->$fieldname : '').'" name="'.$fieldlist[$field].'">';
1981  }
1982  print '</td>';
1983  } elseif ($fieldlist[$field] == 'fk_tva')
1984  {
1985  print '<td>';
1986  print $form->load_tva('fk_tva', $obj->taux, $mysoc, new Societe($db), 0, 0, '', false, -1);
1987  print '</td>';
1988  } elseif ($fieldlist[$field] == 'fk_c_exp_tax_cat')
1989  {
1990  print '<td>';
1991  print $form->selectExpenseCategories($obj->fk_c_exp_tax_cat);
1992  print '</td>';
1993  } elseif ($fieldlist[$field] == 'fk_range')
1994  {
1995  print '<td>';
1996  print $form->selectExpenseRanges($obj->fk_range);
1997  print '</td>';
1998  } else {
1999  $fieldValue = isset($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:'';
2000 
2001  if ($fieldlist[$field] == 'sortorder')
2002  {
2003  $fieldlist[$field] = 'position';
2004  }
2005 
2006  $classtd = ''; $class = '';
2007  if ($fieldlist[$field] == 'code') $class = 'maxwidth100';
2008  if (in_array($fieldlist[$field], array('dayrule', 'day', 'month', 'year', 'pos', 'use_default', 'affect', 'delay', 'position', 'sortorder', 'sens', 'category_type'))) {
2009  $class = 'maxwidth50 center';
2010  }
2011  if (in_array($fieldlist[$field], array('use_default'))) {
2012  $classtd = 'center';
2013  }
2014  if (in_array($fieldlist[$field], array('libelle', 'label', 'tracking'))) $class = 'quatrevingtpercent';
2015  print '<td class="'.$classtd.'">';
2016  $transfound = 0;
2017  $transkey = '';
2018  if (in_array($fieldlist[$field], array('label', 'libelle'))) // For label
2019  {
2020  // Special case for labels
2021  if ($tabname == MAIN_DB_PREFIX.'c_civility') {
2022  $transkey = "Civility".strtoupper($obj->code);
2023  }
2024  if ($tabname == MAIN_DB_PREFIX.'c_payment_term') {
2025  $langs->load("bills");
2026  $transkey = "PaymentConditionShort".strtoupper($obj->code);
2027  }
2028  if ($transkey && $langs->trans($transkey) != $transkey)
2029  {
2030  $transfound = 1;
2031  print $form->textwithpicto($langs->trans($transkey), $langs->trans("GoIntoTranslationMenuToChangeThis"));
2032  }
2033  }
2034  if (!$transfound)
2035  {
2036  print '<input type="text" class="flat'.($class ? ' '.$class : '').'" value="'.dol_escape_htmltag($fieldValue).'" name="'.$fieldlist[$field].'">';
2037  } else {
2038  print '<input type="hidden" name="'.$fieldlist[$field].'" value="'.$transkey.'">';
2039  }
2040  print '</td>';
2041  }
2042  }
2043 
2044  return $withentity;
2045 }
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
getDictvalue($tablename, $field, $id, $checkentity=false, $rowidfield= 'rowid')
Return value from dictionary.
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.
complete_elementList_with_modules(&$elementList)
Search external modules to complete the list of contact element.
Definition: admin.lib.php:1373
if(!empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($arrayfields['country.code_iso']['label'] country if(!empty($arrayfields['typent.code']['checked'])) print_liste_field_titre($arrayfields['typent.code']['label'] typent code
Definition: list.php:566
img_help($usehelpcursor=1, $usealttitle=1)
Show help logo with cursor &quot;?&quot;.
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.
llxHeader()
Empty header.
Definition: wrapper.php:45
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.
Class to manage third parties objects (customers, suppliers, prospects...)
getEntity($element, $shared=1, $currentobject=null)
Get list of entity id to use.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
complete_dictionary_with_modules(&$taborder, &$tabname, &$tablib, &$tabsql, &$tabsqlsort, &$tabfield, &$tabfieldvalue, &$tabfieldinsert, &$tabrowid, &$tabcond, &$tabhelp, &$tabfieldcheck)
Add external modules to list of dictionaries.
Definition: admin.lib.php:1177
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.
if(!GETPOST('transkey', 'alphanohtml')&&!GETPOST('transphrase', 'alphanohtml')) else
View.
Definition: notice.php:44
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...
print $_SERVER["PHP_SELF"]
Edit parameters.
print
Draft customers invoices.
Definition: index.php:89
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.
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
Definition: index.php:1232
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;.
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:1817
length_accountg($account)
Return General accounting account with defined length (used for product and miscellaneous) ...
llxFooter()
Empty footer.
Definition: wrapper.php:59
img_delete($titlealt= 'default', $other= 'class="pictodelete"', $morecss= '')
Show delete logo.
if(!defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN'
Draft customers invoices.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin= '1', $morecss= '', $textfordropdown= '')
Show information for admin users or standard users.
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
Definition: repair.php:105
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $keepmoretags= '', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields...