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