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