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