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