dict.php 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994
  1. <?php
  2. /* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
  4. * Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
  5. * Copyright (C) 2005-2010 Regis Houssin <regis@dolibarr.fr>
  6. * Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es>
  7. * Copyright (C) 2011 Philippe Grand <philippe.grand@atoo-net.com>
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation; either version 2 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  21. */
  22. /**
  23. * \file htdocs/admin/dict.php
  24. * \ingroup setup
  25. * \brief Page to administer data tables
  26. */
  27. require("../main.inc.php");
  28. require_once(DOL_DOCUMENT_ROOT."/core/class/html.formadmin.class.php");
  29. require_once(DOL_DOCUMENT_ROOT."/core/class/html.formcompany.class.php");
  30. require_once(DOL_DOCUMENT_ROOT."/lib/admin.lib.php");
  31. $langs->load("other");
  32. $langs->load("admin");
  33. $langs->load("companies");
  34. if (!$user->admin)
  35. accessforbidden();
  36. $acts[0] = "activate";
  37. $acts[1] = "disable";
  38. //$actl[0] = $langs->trans("Activate");
  39. //$actl[1] = $langs->trans("Disable");
  40. $actl[0] = img_picto($langs->trans("Disabled"),'off');
  41. $actl[1] = img_picto($langs->trans("Activated"),'on');
  42. $listoffset=GETPOST('listoffset');
  43. $listlimit=GETPOST('listlimit')>0?GETPOST('listlimit'):1000;
  44. $active = 1;
  45. $sortfield = GETPOST("sortfield",'alpha');
  46. $sortorder = GETPOST("sortorder",'alpha');
  47. $page = GETPOST("page",'int');
  48. if ($page == -1) { $page = 0 ; }
  49. $offset = $listlimit * $page ;
  50. $pageprev = $page - 1;
  51. $pagenext = $page + 1;
  52. // Cette page est une page d'edition generique des dictionnaires de donnees
  53. // Mettre ici tous les caracteristiques des dictionnaires
  54. // Ordres d'affichage des dictionnaires (0 pour espace)
  55. $taborder=array(9,0,4,3,2,0,1,8,19,16,0,5,11,0,6,0,10,12,13,0,14,0,7,17,0,22,20,18,21,0,15);
  56. // Nom des tables des dictionnaires
  57. $tabname[1] = MAIN_DB_PREFIX."c_forme_juridique";
  58. $tabname[2] = MAIN_DB_PREFIX."c_departements";
  59. $tabname[3] = MAIN_DB_PREFIX."c_regions";
  60. $tabname[4] = MAIN_DB_PREFIX."c_pays";
  61. $tabname[5] = MAIN_DB_PREFIX."c_civilite";
  62. $tabname[6] = MAIN_DB_PREFIX."c_actioncomm";
  63. $tabname[7] = MAIN_DB_PREFIX."c_chargesociales";
  64. $tabname[8] = MAIN_DB_PREFIX."c_typent";
  65. $tabname[9] = MAIN_DB_PREFIX."c_currencies";
  66. $tabname[10]= MAIN_DB_PREFIX."c_tva";
  67. $tabname[11]= MAIN_DB_PREFIX."c_type_contact";
  68. $tabname[12]= MAIN_DB_PREFIX."c_payment_term";
  69. $tabname[13]= MAIN_DB_PREFIX."c_paiement";
  70. $tabname[14]= MAIN_DB_PREFIX."c_ecotaxe";
  71. $tabname[15]= MAIN_DB_PREFIX."c_paper_format";
  72. $tabname[16]= MAIN_DB_PREFIX."c_prospectlevel";
  73. $tabname[17]= MAIN_DB_PREFIX."c_type_fees";
  74. $tabname[18]= MAIN_DB_PREFIX."c_shipment_mode";
  75. $tabname[19]= MAIN_DB_PREFIX."c_effectif";
  76. $tabname[20]= MAIN_DB_PREFIX."c_input_method";
  77. $tabname[21]= MAIN_DB_PREFIX."c_availability";
  78. $tabname[22]= MAIN_DB_PREFIX."c_input_reason";
  79. // Dictionary labels
  80. $tablib[1] = "DictionnaryCompanyJuridicalType";
  81. $tablib[2] = "DictionnaryCanton";
  82. $tablib[3] = "DictionnaryRegion";
  83. $tablib[4] = "DictionnaryCountry";
  84. $tablib[5] = "DictionnaryCivility";
  85. $tablib[6] = "DictionnaryActions";
  86. $tablib[7] = "DictionnarySocialContributions";
  87. $tablib[8] = "DictionnaryCompanyType";
  88. $tablib[9] = "DictionnaryCurrency";
  89. $tablib[10]= "DictionnaryVAT";
  90. $tablib[11]= "DictionnaryTypeContact";
  91. $tablib[12]= "DictionnaryPaymentConditions";
  92. $tablib[13]= "DictionnaryPaymentModes";
  93. $tablib[14]= "DictionnaryEcotaxe";
  94. $tablib[15]= "DictionnaryPaperFormat";
  95. $tablib[16]= "DictionnaryProspectLevel";
  96. $tablib[17]= "DictionnaryFees";
  97. $tablib[18]= "DictionnarySendingMethods";
  98. $tablib[19]= "DictionnaryStaff";
  99. $tablib[20]= "DictionnaryOrderMethods";
  100. $tablib[21]= "DictionnaryAvailability";
  101. $tablib[22]= "DictionnarySource";
  102. // Requete pour extraction des donnees des dictionnaires
  103. $tabsql[1] = "SELECT f.rowid as rowid, f.code, f.libelle, p.code as pays_code, p.libelle as pays, f.active FROM ".MAIN_DB_PREFIX."c_forme_juridique as f, ".MAIN_DB_PREFIX."c_pays as p WHERE f.fk_pays=p.rowid";
  104. $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, p.code as pays_code, p.libelle as pays, d.active FROM ".MAIN_DB_PREFIX."c_departements as d, ".MAIN_DB_PREFIX."c_regions as r, ".MAIN_DB_PREFIX."c_pays as p WHERE d.fk_region=r.code_region and r.fk_pays=p.rowid and r.active=1 and p.active=1";
  105. $tabsql[3] = "SELECT r.rowid as rowid, code_region as code, nom as libelle, r.fk_pays as pays_id, p.code as pays_code, p.libelle as pays, r.active FROM ".MAIN_DB_PREFIX."c_regions as r, ".MAIN_DB_PREFIX."c_pays as p WHERE r.fk_pays=p.rowid and p.active=1";
  106. $tabsql[4] = "SELECT rowid as rowid, code, libelle, active FROM ".MAIN_DB_PREFIX."c_pays";
  107. $tabsql[5] = "SELECT c.rowid as rowid, c.code as code, c.civilite AS libelle, c.active FROM ".MAIN_DB_PREFIX."c_civilite AS c";
  108. $tabsql[6] = "SELECT a.id as rowid, a.code as code, a.libelle AS libelle, a.type, a.active, a.module, a.position FROM ".MAIN_DB_PREFIX."c_actioncomm AS a";
  109. $tabsql[7] = "SELECT a.id as rowid, a.code as code, a.libelle AS libelle, a.deductible, p.code as pays_code, p.libelle as pays, a.fk_pays as pays_id, a.active FROM ".MAIN_DB_PREFIX."c_chargesociales AS a, ".MAIN_DB_PREFIX."c_pays as p WHERE a.fk_pays=p.rowid and p.active=1";
  110. $tabsql[8] = "SELECT id as rowid, code, libelle, active FROM ".MAIN_DB_PREFIX."c_typent";
  111. //$tabsql[9] = "SELECT code, code_iso, label as libelle, symbole, active FROM ".MAIN_DB_PREFIX."c_currencies";
  112. $tabsql[9] = "SELECT code, code_iso, label as libelle, active FROM ".MAIN_DB_PREFIX."c_currencies";
  113. $tabsql[10]= "SELECT t.rowid, t.taux, t.localtax1, t.localtax2, p.libelle as pays, p.code as pays_code, t.fk_pays as pays_id, t.recuperableonly, t.note, t.active FROM ".MAIN_DB_PREFIX."c_tva as t, llx_c_pays as p WHERE t.fk_pays=p.rowid";
  114. $tabsql[11]= "SELECT t.rowid as rowid, element, source, code, libelle, active FROM ".MAIN_DB_PREFIX."c_type_contact AS t";
  115. $tabsql[12]= "SELECT c.rowid as rowid, code, sortorder, c.libelle, c.libelle_facture, nbjour, fdm, decalage, active FROM ".MAIN_DB_PREFIX.'c_payment_term AS c';
  116. $tabsql[13]= "SELECT id as rowid, code, c.libelle, type, active FROM ".MAIN_DB_PREFIX."c_paiement AS c";
  117. $tabsql[14]= "SELECT e.rowid as rowid, e.code as code, e.libelle, e.price, e.organization, e.fk_pays as pays_id, p.code as pays_code, p.libelle as pays, e.active FROM ".MAIN_DB_PREFIX."c_ecotaxe AS e, ".MAIN_DB_PREFIX."c_pays as p WHERE e.fk_pays=p.rowid and p.active=1";
  118. $tabsql[15]= "SELECT rowid as rowid, code, label as libelle, width, height, unit, active FROM ".MAIN_DB_PREFIX."c_paper_format";
  119. $tabsql[16]= "SELECT code, label as libelle, active FROM ".MAIN_DB_PREFIX."c_prospectlevel";
  120. $tabsql[17]= "SELECT id as rowid, code, libelle, active FROM ".MAIN_DB_PREFIX."c_type_fees";
  121. $tabsql[18]= "SELECT rowid as rowid, code, libelle, active FROM ".MAIN_DB_PREFIX."c_shipment_mode";
  122. $tabsql[19]= "SELECT id as rowid, code, libelle, active FROM ".MAIN_DB_PREFIX."c_effectif";
  123. $tabsql[20]= "SELECT rowid as rowid, code, libelle, active FROM ".MAIN_DB_PREFIX."c_input_method";
  124. $tabsql[21]= "SELECT c.rowid as rowid, code, label, active FROM ".MAIN_DB_PREFIX."c_availability AS c";
  125. $tabsql[22]= "SELECT rowid as rowid, code, label, active FROM ".MAIN_DB_PREFIX."c_input_reason";
  126. // Critere de tri du dictionnaire
  127. $tabsqlsort[1] ="pays ASC, code ASC";
  128. $tabsqlsort[2] ="pays ASC, code ASC";
  129. $tabsqlsort[3] ="pays ASC, code ASC";
  130. $tabsqlsort[4] ="code ASC";
  131. $tabsqlsort[5] ="libelle ASC";
  132. $tabsqlsort[6] ="a.type ASC, a.module, a.position, a.code ASC";
  133. $tabsqlsort[7] ="pays ASC, code ASC, a.libelle ASC";
  134. $tabsqlsort[8] ="libelle ASC";
  135. $tabsqlsort[9] ="code ASC";
  136. $tabsqlsort[10]="pays ASC, taux ASC, recuperableonly ASC, localtax1 ASC, localtax2 ASC";
  137. $tabsqlsort[11]="element ASC, source ASC, code ASC";
  138. $tabsqlsort[12]="sortorder ASC, code ASC";
  139. $tabsqlsort[13]="code ASC";
  140. $tabsqlsort[14]="pays ASC, e.organization ASC, code ASC";
  141. $tabsqlsort[15]="rowid ASC";
  142. $tabsqlsort[16]="sortorder ASC";
  143. $tabsqlsort[17]="code ASC";
  144. $tabsqlsort[18]="code ASC, libelle ASC";
  145. $tabsqlsort[19]="id ASC";
  146. $tabsqlsort[20]="code ASC, libelle ASC";
  147. $tabsqlsort[21]="code ASC, label ASC";
  148. $tabsqlsort[22]="code ASC, label ASC";
  149. // Nom des champs en resultat de select pour affichage du dictionnaire
  150. $tabfield[1] = "code,libelle,pays";
  151. $tabfield[2] = "code,libelle,region_id,region,pays"; // "code,libelle,region,pays_code-pays"
  152. $tabfield[3] = "code,libelle,pays_id,pays";
  153. $tabfield[4] = "code,libelle";
  154. $tabfield[5] = "code,libelle";
  155. $tabfield[6] = "code,libelle,type,position";
  156. $tabfield[7] = "code,libelle,pays_id,pays,deductible";
  157. $tabfield[8] = "code,libelle";
  158. //$tabfield[9] = "code,code_iso,libelle,symbole";
  159. $tabfield[9] = "code,code_iso,libelle";
  160. $tabfield[10]= "pays_id,pays,taux,recuperableonly,localtax1,localtax2,note";
  161. $tabfield[11]= "element,source,code,libelle";
  162. $tabfield[12]= "code,libelle,libelle_facture,nbjour,fdm,decalage";
  163. $tabfield[13]= "code,libelle,type";
  164. $tabfield[14]= "code,libelle,price,organization,pays_id,pays";
  165. $tabfield[15]= "code,libelle,width,height,unit";
  166. $tabfield[16]= "code,libelle";
  167. $tabfield[17]= "code,libelle";
  168. $tabfield[18]= "code,libelle";
  169. $tabfield[19]= "code,libelle";
  170. $tabfield[20]= "code,libelle";
  171. $tabfield[21]= "code,label";
  172. $tabfield[22]= "code,label";
  173. // Nom des champs d'edition pour modification d'un enregistrement
  174. $tabfieldvalue[1] = "code,libelle,pays";
  175. $tabfieldvalue[2] = "code,libelle,region"; // "code,libelle,region"
  176. $tabfieldvalue[3] = "code,libelle,pays";
  177. $tabfieldvalue[4] = "code,libelle";
  178. $tabfieldvalue[5] = "code,libelle";
  179. $tabfieldvalue[6] = "code,libelle,type,position";
  180. $tabfieldvalue[7] = "code,libelle,pays,deductible";
  181. $tabfieldvalue[8] = "code,libelle";
  182. //$tabfieldvalue[9] = "code,code_iso,libelle,symbole";
  183. $tabfieldvalue[9] = "code,code_iso,libelle";
  184. $tabfieldvalue[10]= "pays,taux,recuperableonly,localtax1,localtax2,note";
  185. $tabfieldvalue[11]= "element,source,code,libelle";
  186. $tabfieldvalue[12]= "code,libelle,libelle_facture,nbjour,fdm,decalage";
  187. $tabfieldvalue[13]= "code,libelle,type";
  188. $tabfieldvalue[14]= "code,libelle,price,organization,pays";
  189. $tabfieldvalue[15]= "code,libelle,width,height,unit";
  190. $tabfieldvalue[16]= "code,libelle";
  191. $tabfieldvalue[17]= "code,libelle";
  192. $tabfieldvalue[18]= "code,libelle";
  193. $tabfieldvalue[19]= "code,libelle";
  194. $tabfieldvalue[20]= "code,libelle";
  195. $tabfieldvalue[21]= "code,label";
  196. $tabfieldvalue[22]= "code,label";
  197. // Nom des champs dans la table pour insertion d'un enregistrement
  198. $tabfieldinsert[1] = "code,libelle,fk_pays";
  199. $tabfieldinsert[2] = "code_departement,nom,fk_region";
  200. $tabfieldinsert[3] = "code_region,nom,fk_pays";
  201. $tabfieldinsert[4] = "code,libelle";
  202. $tabfieldinsert[5] = "code,civilite";
  203. $tabfieldinsert[6] = "code,libelle,type,position";
  204. $tabfieldinsert[7] = "code,libelle,fk_pays,deductible";
  205. $tabfieldinsert[8] = "code,libelle";
  206. //$tabfieldinsert[9] = "code,code_iso,label,symbole";
  207. $tabfieldinsert[9] = "code,code_iso,label";
  208. $tabfieldinsert[10]= "fk_pays,taux,recuperableonly,localtax1,localtax2,note";
  209. $tabfieldinsert[11]= "element,source,code,libelle";
  210. $tabfieldinsert[12]= "code,libelle,libelle_facture,nbjour,fdm,decalage";
  211. $tabfieldinsert[13]= "code,libelle,type";
  212. $tabfieldinsert[14]= "code,libelle,price,organization,fk_pays";
  213. $tabfieldinsert[15]= "code,label,width,height,unit";
  214. $tabfieldinsert[16]= "code,label";
  215. $tabfieldinsert[17]= "code,libelle";
  216. $tabfieldinsert[18]= "code,libelle";
  217. $tabfieldinsert[19]= "code,libelle";
  218. $tabfieldinsert[20]= "code,libelle";
  219. $tabfieldinsert[21]= "code,label";
  220. $tabfieldinsert[22]= "code,label";
  221. // Nom du rowid si le champ n'est pas de type autoincrement
  222. // Example: "" if id field is "rowid" and has autoincrement on
  223. // "nameoffield" if id field is not "rowid" or has not autoincrement on
  224. $tabrowid[1] = "";
  225. $tabrowid[2] = "";
  226. $tabrowid[3] = "";
  227. $tabrowid[4] = "rowid";
  228. $tabrowid[5] = "rowid";
  229. $tabrowid[6] = "id";
  230. $tabrowid[7] = "id";
  231. $tabrowid[8] = "id";
  232. $tabrowid[9] = "code";
  233. $tabrowid[10]= "";
  234. $tabrowid[11]= "rowid";
  235. $tabrowid[12]= "rowid";
  236. $tabrowid[13]= "id";
  237. $tabrowid[14]= "";
  238. $tabrowid[15]= "";
  239. $tabrowid[16]= "code";
  240. $tabrowid[17]= "id";
  241. $tabrowid[18]= "rowid";
  242. $tabrowid[19]= "id";
  243. $tabrowid[20]= "";
  244. $tabrowid[21]= "rowid";
  245. $tabrowid[22]= "rowid";
  246. // Condition to show dictionnary in setup page
  247. $tabcond[1] = true;
  248. $tabcond[2] = true;
  249. $tabcond[3] = true;
  250. $tabcond[4] = true;
  251. $tabcond[5] = $conf->societe->enabled||$conf->adherent->enabled;
  252. $tabcond[6] = $conf->agenda->enabled;
  253. $tabcond[7] = $conf->tax->enabled;
  254. $tabcond[8] = $conf->societe->enabled;
  255. $tabcond[9] = true;
  256. $tabcond[10]= true;
  257. $tabcond[11]= true;
  258. $tabcond[12]= $conf->commande->enabled||$conf->propale->enabled||$conf->facture->enabled||$conf->fournisseur->enabled;
  259. $tabcond[13]= $conf->commande->enabled||$conf->propale->enabled||$conf->facture->enabled||$conf->fournisseur->enabled;
  260. $tabcond[14]= $conf->product->enabled&&$conf->ecotax->enabled;
  261. $tabcond[15]= true;
  262. $tabcond[16]= $conf->societe->enabled && empty($conf->global->SOCIETE_DISABLE_PROSPECTS);
  263. $tabcond[17]= $conf->deplacement->enabled;
  264. $tabcond[18]= $conf->expedition->enabled;
  265. $tabcond[19]= $conf->societe->enabled;
  266. $tabcond[20]= $conf->fournisseur->enabled;
  267. $tabcond[21]= $conf->propale->enabled;
  268. $tabcond[22]= $conf->commande->enabled||$conf->propale->enabled;
  269. complete_dictionnary_with_modules($taborder,$tabname,$tablib,$tabsql,$tabsqlsort,$tabfield,$tabfieldvalue,$tabfieldinsert,$tabrowid,$tabcond);
  270. // Define elementList and sourceList (used for dictionnary "type of contacts")
  271. $elementList = array();
  272. $sourceList=array();
  273. if (GETPOST("id") == 11)
  274. {
  275. $langs->load("orders");
  276. $langs->load("contracts");
  277. $langs->load("projects");
  278. $langs->load("propal");
  279. $langs->load("bills");
  280. $langs->load("interventions");
  281. $elementList = array("commande"=>$langs->trans("Order"),
  282. "order_supplier"=>$langs->trans("SupplierOrder"),
  283. "contrat"=>$langs->trans("Contract"),
  284. "project"=>$langs->trans("Project"),
  285. "project_task"=>$langs->trans("Task"),
  286. "propal"=>$langs->trans("Propal"),
  287. "facture"=>$langs->trans("Bill"),
  288. "facture_fourn"=>$langs->trans("SupplierBill"),
  289. "fichinter"=>$langs->trans("InterventionCard"));
  290. if ($conf->global->MAIN_SUPPORT_CONTACT_TYPE_FOR_THIRDPARTIES) $elementList["societe"]=$langs->trans("ThirdParty");
  291. $sourceList = array("internal"=>$langs->trans("Internal"),
  292. "external"=>$langs->trans("External"));
  293. }
  294. $msg='';
  295. /*
  296. * Actions ajout ou modification d'une entree dans un dictionnaire de donnee
  297. */
  298. if ($_POST["actionadd"] || $_POST["actionmodify"])
  299. {
  300. $listfield=explode(',',$tabfield[$_POST["id"]]);
  301. $listfieldinsert=explode(',',$tabfieldinsert[$_POST["id"]]);
  302. $listfieldmodify=explode(',',$tabfieldinsert[$_POST["id"]]);
  303. $listfieldvalue=explode(',',$tabfieldvalue[$_POST["id"]]);
  304. // Check that all fields are filled
  305. $ok=1;
  306. foreach ($listfield as $f => $value)
  307. {
  308. if ($value == 'pays')
  309. {
  310. if (in_array('region_id',$listfield)) { continue; } // For region page, we do not require the country input
  311. }
  312. if ((! isset($_POST[$value]) || $_POST[$value]=='')
  313. && $listfield[$f] != 'decalage' // Fields that are not mandatory
  314. && $listfield[$f] != 'module') // Fields that are not mandatory
  315. {
  316. $ok=0;
  317. $fieldnamekey=$listfield[$f];
  318. // We take translate key of field
  319. if ($fieldnamekey == 'libelle') $fieldnamekey='Label';
  320. if ($fieldnamekey == 'nbjour') $fieldnamekey='NbOfDays';
  321. if ($fieldnamekey == 'decalage') $fieldnamekey='Offset';
  322. if ($fieldnamekey == 'module') $fieldnamekey='Module';
  323. $msg.=$langs->trans("ErrorFieldRequired",$langs->transnoentities($fieldnamekey)).'<br>';
  324. }
  325. }
  326. // Autres verif
  327. if ($tabname[$_POST["id"]] == MAIN_DB_PREFIX."c_actioncomm" && isset($_POST["type"]) && $_POST["type"]=='system') {
  328. $ok=0;
  329. $msg.="Value 'system' for type is reserved. You can use 'user' as value to add your own record.<br>";
  330. }
  331. if (isset($_POST["code"]) && $_POST["code"]=='0') {
  332. $ok=0;
  333. $msg.="Code can't contains value 0<br>";
  334. }
  335. if (isset($_POST["pays"]) && $_POST["pays"]=='0') {
  336. $ok=0;
  337. $msg.=$langs->trans("ErrorFieldRequired",$langs->trans("Country")).'<br>';
  338. }
  339. // Si verif ok et action add, on ajoute la ligne
  340. if ($ok && $_POST["actionadd"])
  341. {
  342. if ($tabrowid[$_POST["id"]])
  343. {
  344. // Recupere id libre pour insertion
  345. $newid=0;
  346. $sql = "SELECT max(".$tabrowid[$_POST["id"]].") newid from ".$tabname[$_POST["id"]];
  347. $result = $db->query($sql);
  348. if ($result)
  349. {
  350. $obj = $db->fetch_object($result);
  351. $newid=($obj->newid + 1);
  352. } else {
  353. dol_print_error($db);
  354. }
  355. }
  356. // Add new entry
  357. $sql = "INSERT INTO ".$tabname[$_POST["id"]]." (";
  358. // List of fields
  359. if ($tabrowid[$_POST["id"]] &&
  360. ! in_array($tabrowid[$_POST["id"]],$listfieldinsert)) $sql.= $tabrowid[$_POST["id"]].",";
  361. $sql.= $tabfieldinsert[$_POST["id"]];
  362. $sql.=",active)";
  363. $sql.= " VALUES(";
  364. // List of values
  365. if ($tabrowid[$_POST["id"]] &&
  366. ! in_array($tabrowid[$_POST["id"]],$listfieldinsert)) $sql.= $newid.",";
  367. $i=0;
  368. foreach ($listfieldinsert as $f => $value)
  369. {
  370. if ($value == 'price') { $_POST[$listfieldvalue[$i]] = price2num($_POST[$listfieldvalue[$i]],'MU'); }
  371. if ($i) $sql.=",";
  372. if ($_POST[$listfieldvalue[$i]] == '') $sql.="null";
  373. else $sql.="'".$db->escape($_POST[$listfieldvalue[$i]])."'";
  374. $i++;
  375. }
  376. $sql.=",1)";
  377. dol_syslog("actionadd sql=".$sql);
  378. $result = $db->query($sql);
  379. if ($result) // Add is ok
  380. {
  381. $oldid=$_POST["id"];
  382. $_POST=array('id'=>$oldid); // Clean $_POST array, we keep only
  383. $_GET["id"]=$_POST["id"]; // Force affichage dictionnaire en cours d'edition
  384. }
  385. else
  386. {
  387. if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
  388. $msg=$langs->trans("ErrorRecordAlreadyExists").'<br>';
  389. }
  390. else {
  391. dol_print_error($db);
  392. }
  393. }
  394. }
  395. // Si verif ok et action modify, on modifie la ligne
  396. if ($ok && $_POST["actionmodify"])
  397. {
  398. if ($tabrowid[$_POST["id"]]) { $rowidcol=$tabrowid[$_POST["id"]]; }
  399. else { $rowidcol="rowid"; }
  400. // Modify entry
  401. $sql = "UPDATE ".$tabname[$_POST["id"]]." SET ";
  402. // Modifie valeur des champs
  403. if ($tabrowid[$_POST["id"]] && !in_array($tabrowid[$_POST["id"]],$listfieldmodify))
  404. {
  405. $sql.= $tabrowid[$_POST["id"]]."=";
  406. $sql.= "'".$db->escape($_POST["rowid"])."', ";
  407. }
  408. $i = 0;
  409. foreach ($listfieldmodify as $field)
  410. {
  411. if ($field == 'price') { $_POST[$listfieldvalue[$i]] = price2num($_POST[$listfieldvalue[$i]],'MU'); }
  412. if ($i) $sql.=",";
  413. $sql.= $field."=";
  414. if ($_POST[$listfieldvalue[$i]] == '') $sql.="null";
  415. else $sql.="'".$db->escape($_POST[$listfieldvalue[$i]])."'";
  416. $i++;
  417. }
  418. $sql.= " WHERE ".$rowidcol." = '".$_POST["rowid"]."'";
  419. dol_syslog("actionmodify sql=".$sql);
  420. //print $sql;
  421. $resql = $db->query($sql);
  422. if (! $resql)
  423. {
  424. $msg=$db->error();
  425. }
  426. }
  427. if ($msg) $msg='<div class="error">'.$msg.'</div>';
  428. $_GET["id"]=$_POST["id"]; // Force affichage dictionnaire en cours d'edition
  429. }
  430. if ($_POST["actioncancel"])
  431. {
  432. $_GET["id"]=$_POST["id"]; // Force affichage dictionnaire en cours d'edition
  433. }
  434. if ($_REQUEST['action'] == 'confirm_delete' && $_REQUEST['confirm'] == 'yes') // delete
  435. {
  436. if ($tabrowid[$_GET["id"]]) { $rowidcol=$tabrowid[$_GET["id"]]; }
  437. else { $rowidcol="rowid"; }
  438. $sql = "DELETE from ".$tabname[$_GET["id"]]." WHERE ".$rowidcol."='".$_GET["rowid"]."'";
  439. dol_syslog("delete sql=".$sql);
  440. $result = $db->query($sql);
  441. if (! $result)
  442. {
  443. if ($db->errno() == 'DB_ERROR_CHILD_EXISTS')
  444. {
  445. $msg='<div class="error">'.$langs->trans("ErrorRecordIsUsedByChild").'</div>';
  446. }
  447. else
  448. {
  449. dol_print_error($db);
  450. }
  451. }
  452. }
  453. if ($_GET["action"] == $acts[0]) // activate
  454. {
  455. if ($tabrowid[$_GET["id"]]) { $rowidcol=$tabrowid[$_GET["id"]]; }
  456. else { $rowidcol="rowid"; }
  457. if ($_GET["rowid"]) {
  458. $sql = "UPDATE ".$tabname[$_GET["id"]]." SET active = 1 WHERE ".$rowidcol."='".$_GET["rowid"]."'";
  459. }
  460. elseif ($_GET["code"]) {
  461. $sql = "UPDATE ".$tabname[$_GET["id"]]." SET active = 1 WHERE code='".$_GET["code"]."'";
  462. }
  463. $result = $db->query($sql);
  464. if (!$result)
  465. {
  466. dol_print_error($db);
  467. }
  468. }
  469. if ($_GET["action"] == $acts[1]) // disable
  470. {
  471. if ($tabrowid[$_GET["id"]]) { $rowidcol=$tabrowid[$_GET["id"]]; }
  472. else { $rowidcol="rowid"; }
  473. if ($_GET["rowid"]) {
  474. $sql = "UPDATE ".$tabname[$_GET["id"]]." SET active = 0 WHERE ".$rowidcol."='".$_GET["rowid"]."'";
  475. }
  476. elseif ($_GET["code"]) {
  477. $sql = "UPDATE ".$tabname[$_GET["id"]]." SET active = 0 WHERE code='".$_GET["code"]."'";
  478. }
  479. $result = $db->query($sql);
  480. if (!$result)
  481. {
  482. dol_print_error($db);
  483. }
  484. }
  485. /*
  486. * View
  487. */
  488. $html = new Form($db);
  489. $formadmin=new FormAdmin($db);
  490. llxHeader();
  491. $titre=$langs->trans("DictionnarySetup");
  492. $linkback='';
  493. if ($_GET["id"])
  494. {
  495. $titre.=' - '.$langs->trans($tablib[$_GET["id"]]);
  496. $linkback='<a href="'.DOL_URL_ROOT.'/admin/dict.php">'.$langs->trans("BackToDictionnaryList").'</a>';
  497. }
  498. print_fiche_titre($titre,$linkback,'setup');
  499. if (empty($_GET["id"]))
  500. {
  501. print $langs->trans("DictionnaryDesc");
  502. print " ".$langs->trans("OnlyActiveElementsAreShown")."<br>\n";
  503. }
  504. print "<br>\n";
  505. /*
  506. * Confirmation de la suppression de la ligne
  507. */
  508. if ($_GET['action'] == 'delete')
  509. {
  510. $ret=$html->form_confirm($_SERVER["PHP_SELF"].'?'.($page?'page='.$page.'&':'').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.$_GET["rowid"].'&code='.$_GET["code"].'&id='.$_GET["id"], $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_delete','',0,1);
  511. if ($ret == 'html') print '<br>';
  512. }
  513. /*
  514. * Show a dictionnary
  515. */
  516. if ($_GET["id"])
  517. {
  518. if ($msg)
  519. {
  520. print $msg.'<br>';
  521. }
  522. // Complete requete recherche valeurs avec critere de tri
  523. $sql=$tabsql[$_GET["id"]];
  524. if ($_GET["sortfield"])
  525. {
  526. // If sort order is "pays", we use pays_code instead
  527. if ($_GET["sortfield"] == 'pays') $_GET["sortfield"]='pays_code';
  528. $sql.= " ORDER BY ".$_GET["sortfield"];
  529. if ($_GET["sortorder"])
  530. {
  531. $sql.=" ".strtoupper($_GET["sortorder"]);
  532. }
  533. $sql.=", ";
  534. // Remove from default sort order the choosed order
  535. $tabsqlsort[$_GET["id"]]=preg_replace('/'.$_GET["sortfield"].' '.$_GET["sortorder"].',/i','',$tabsqlsort[$_GET["id"]]);
  536. $tabsqlsort[$_GET["id"]]=preg_replace('/'.$_GET["sortfield"].',/i','',$tabsqlsort[$_GET["id"]]);
  537. }
  538. else {
  539. $sql.=" ORDER BY ";
  540. }
  541. $sql.=$tabsqlsort[$_GET["id"]];
  542. $sql.=$db->plimit($listlimit+1,$offset);
  543. //print $sql;
  544. $fieldlist=explode(',',$tabfield[$_GET["id"]]);
  545. print '<form action="dict.php" method="post">';
  546. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  547. print '<table class="noborder" width="100%">';
  548. // Form to add a new line
  549. if ($tabname[$_GET["id"]])
  550. {
  551. $alabelisused=0;
  552. $var=false;
  553. $fieldlist=explode(',',$tabfield[$_GET["id"]]);
  554. // print '<table class="noborder" width="100%">';
  555. // Line for title
  556. print '<tr class="liste_titre">';
  557. foreach ($fieldlist as $field => $value)
  558. {
  559. // Determine le nom du champ par rapport aux noms possibles
  560. // dans les dictionnaires de donnees
  561. $valuetoshow=ucfirst($fieldlist[$field]); // Par defaut
  562. if ($fieldlist[$field]=='source') { $valuetoshow=$langs->trans("Contact"); }
  563. if ($fieldlist[$field]=='price') { $valuetoshow=$langs->trans("PriceUHT"); }
  564. if ($fieldlist[$field]=='taux') { $valuetoshow=$langs->trans("Rate"); }
  565. if ($fieldlist[$field]=='organization') { $valuetoshow=$langs->trans("Organization"); }
  566. if ($fieldlist[$field]=='lang') { $valuetoshow=$langs->trans("Language"); }
  567. if ($fieldlist[$field]=='type') { $valuetoshow=$langs->trans("Type"); }
  568. if ($fieldlist[$field]=='code') { $valuetoshow=$langs->trans("Code"); }
  569. if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') { $valuetoshow=$langs->trans("Label")."*"; }
  570. if ($fieldlist[$field]=='libelle_facture') { $valuetoshow=$langs->trans("LabelOnDocuments")."*"; }
  571. if ($fieldlist[$field]=='pays') {
  572. if (in_array('region_id',$fieldlist)) { print '<td>&nbsp;</td>'; continue; } // For region page, we do not show the country input
  573. $valuetoshow=$langs->trans("Country"); }
  574. if ($fieldlist[$field]=='recuperableonly') { $valuetoshow=MAIN_LABEL_MENTION_NPR; }
  575. if ($fieldlist[$field]=='nbjour') { $valuetoshow=$langs->trans("NbOfDays"); }
  576. if ($fieldlist[$field]=='fdm') { $valuetoshow=$langs->trans("AtEndOfMonth"); }
  577. if ($fieldlist[$field]=='decalage') { $valuetoshow=$langs->trans("Offset"); }
  578. if ($fieldlist[$field]=='width') { $valuetoshow=$langs->trans("Width"); }
  579. if ($fieldlist[$field]=='height') { $valuetoshow=$langs->trans("Height"); }
  580. if ($fieldlist[$field]=='unit') { $valuetoshow=$langs->trans("MeasuringUnit"); }
  581. if ($fieldlist[$field]=='region_id' || $fieldlist[$field]=='pays_id') { $valuetoshow=''; }
  582. if ($valuetoshow != '')
  583. {
  584. print '<td>';
  585. print $valuetoshow;
  586. print '</td>';
  587. }
  588. if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') $alabelisused=1;
  589. }
  590. print '<td colspan="3">';
  591. print '<input type="hidden" name="id" value="'.$_GET["id"].'">';
  592. print '&nbsp;</td>';
  593. print '</tr>';
  594. // Line to type new values
  595. print "<tr ".$bc[$var].">";
  596. $obj='';
  597. // If data was already input, we define them in obj to populate input fields.
  598. if ($_POST["actionadd"])
  599. {
  600. foreach ($fieldlist as $key=>$val)
  601. {
  602. if (! empty($_POST[$val])) $obj->$val=$_POST[$val];
  603. }
  604. }
  605. fieldList($fieldlist,$obj);
  606. print '<td colspan="3" align="right"><input type="submit" class="button" name="actionadd" value="'.$langs->trans("Add").'"></td>';
  607. print "</tr>";
  608. if ($alabelisused) // Si un des champs est un libelle
  609. {
  610. print '<tr><td colspan="'.(count($fieldlist)+2).'">* '.$langs->trans("LabelUsedByDefault").'.</td></tr>';
  611. }
  612. print '<tr><td colspan="'.(count($fieldlist)+2).'">&nbsp;</td></tr>';
  613. }
  614. // List of available values in database
  615. dol_syslog("htdocs/admin/dict sql=".$sql, LOG_DEBUG);
  616. $resql=$db->query($sql);
  617. if ($resql)
  618. {
  619. $num = $db->num_rows($resql);
  620. $i = 0;
  621. $var=true;
  622. if ($num)
  623. {
  624. // There is several pages
  625. if ($num > $listlimit)
  626. {
  627. print '<tr class="none"><td align="right" colspan="'.(3+sizeof($fieldlist)).'">';
  628. print_fleche_navigation($page,$_SERVER["PHP_SELF"],'&id='.GETPOST('id'),($num > $listlimit),$langs->trans("Page").' '.($page+1));
  629. print '</td></tr>';
  630. }
  631. // Title of lines
  632. print '<tr class="liste_titre">';
  633. foreach ($fieldlist as $field => $value)
  634. {
  635. // Determine le nom du champ par rapport aux noms possibles
  636. // dans les dictionnaires de donnees
  637. $showfield=1; // Par defaut
  638. $valuetoshow=ucfirst($fieldlist[$field]); // Par defaut
  639. if ($fieldlist[$field]=='source') { $valuetoshow=$langs->trans("Contact"); }
  640. if ($fieldlist[$field]=='price') { $valuetoshow=$langs->trans("PriceUHT"); }
  641. if ($fieldlist[$field]=='taux') { $valuetoshow=$langs->trans("Rate"); }
  642. if ($fieldlist[$field]=='organization') { $valuetoshow=$langs->trans("Organization"); }
  643. if ($fieldlist[$field]=='lang') { $valuetoshow=$langs->trans("Language"); }
  644. if ($fieldlist[$field]=='type') { $valuetoshow=$langs->trans("Type"); }
  645. if ($fieldlist[$field]=='code') { $valuetoshow=$langs->trans("Code"); }
  646. if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') { $valuetoshow=$langs->trans("Label")."*"; }
  647. if ($fieldlist[$field]=='libelle_facture') { $valuetoshow=$langs->trans("LabelOnDocuments")."*"; }
  648. if ($fieldlist[$field]=='pays') { $valuetoshow=$langs->trans("Country"); }
  649. if ($fieldlist[$field]=='recuperableonly') { $valuetoshow=MAIN_LABEL_MENTION_NPR; }
  650. if ($fieldlist[$field]=='nbjour') { $valuetoshow=$langs->trans("NbOfDays"); }
  651. if ($fieldlist[$field]=='fdm') { $valuetoshow=$langs->trans("AtEndOfMonth"); }
  652. if ($fieldlist[$field]=='decalage') { $valuetoshow=$langs->trans("Offset"); }
  653. if ($fieldlist[$field]=='width') { $valuetoshow=$langs->trans("Width"); }
  654. if ($fieldlist[$field]=='height') { $valuetoshow=$langs->trans("Height"); }
  655. if ($fieldlist[$field]=='unit') { $valuetoshow=$langs->trans("MeasuringUnit"); }
  656. if ($fieldlist[$field]=='region_id' || $fieldlist[$field]=='pays_id') { $showfield=0; }
  657. // Affiche nom du champ
  658. if ($showfield)
  659. {
  660. print_liste_field_titre($valuetoshow,"dict.php",$fieldlist[$field],($page?'page='.$page.'&':'').'&id='.GETPOST("id"),"","",$sortfield,$sortorder);
  661. }
  662. }
  663. print_liste_field_titre($langs->trans("Status"),"dict.php","active",($page?'page='.$page.'&':'').'&id='.GETPOST("id"),"",'align="center"',$sortfield,$sortorder);
  664. print '<td colspan="2" class="liste_titre">&nbsp;</td>';
  665. print '</tr>';
  666. // Lines with values
  667. while ($i < $num)
  668. {
  669. $obj = $db->fetch_object($resql);
  670. $var=!$var;
  671. //print_r($obj);
  672. print "<tr ".$bc[$var].">";
  673. if ($_GET["action"] == 'modify' && ($_GET["rowid"] == ($obj->rowid?$obj->rowid:$obj->code)))
  674. {
  675. print '<form action="dict.php" method="post">';
  676. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  677. print '<input type="hidden" name="id" value="'.GETPOST("id").'">';
  678. print '<input type="hidden" name="page" value="'.$page.'">';
  679. print '<input type="hidden" name="rowid" value="'.$_GET["rowid"].'">';
  680. fieldList($fieldlist,$obj);
  681. print '<td colspan="3" align="right"><a name="'.($obj->rowid?$obj->rowid:$obj->code).'">&nbsp;</a><input type="submit" class="button" name="actionmodify" value="'.$langs->trans("Modify").'">';
  682. print '&nbsp;<input type="submit" class="button" name="actioncancel" value="'.$langs->trans("Cancel").'"></td>';
  683. }
  684. else
  685. {
  686. foreach ($fieldlist as $field => $value)
  687. {
  688. $showfield=1;
  689. $valuetoshow=$obj->$fieldlist[$field];
  690. if ($valuetoshow=='all') {
  691. $valuetoshow=$langs->trans('All');
  692. }
  693. else if ($fieldlist[$field]=='pays') {
  694. if (empty($obj->pays_code))
  695. {
  696. $valuetoshow='-';
  697. }
  698. else
  699. {
  700. $key=$langs->trans("Country".strtoupper($obj->pays_code));
  701. $valuetoshow=($key != "Country".strtoupper($obj->pays_code))?$obj->pays_code." - ".$key:$obj->pays;
  702. }
  703. }
  704. else if ($fieldlist[$field]=='recuperableonly' || $fieldlist[$field]=='fdm') {
  705. $valuetoshow=yn($valuetoshow);
  706. }
  707. else if ($fieldlist[$field]=='price') {
  708. $valuetoshow=price($valuetoshow);
  709. }
  710. else if ($fieldlist[$field]=='price') {
  711. $valuetoshow=price($valuetoshow);
  712. }
  713. else if ($fieldlist[$field]=='libelle_facture') {
  714. $valuetoshow=nl2br($valuetoshow);
  715. }
  716. else if ($fieldlist[$field]=='libelle' && $tabname[$_GET["id"]]=='llx_c_pays') {
  717. $key=$langs->trans("Country".strtoupper($obj->code));
  718. $valuetoshow=($obj->code && $key != "Country".strtoupper($obj->code))?$key:$obj->$fieldlist[$field];
  719. }
  720. else if ($fieldlist[$field]=='region_id' || $fieldlist[$field]=='pays_id') {
  721. $showfield=0;
  722. }
  723. if ($showfield) print '<td>'.$valuetoshow.'</td>';
  724. }
  725. print '<td align="center" nowrap="nowrap">';
  726. // Est-ce une entree du dictionnaire qui peut etre desactivee ?
  727. $iserasable=1; // Oui par defaut
  728. if (isset($obj->code) && ($obj->code == '0' || $obj->code == '' || preg_match('/unknown/i',$obj->code))) $iserasable=0;
  729. if (isset($obj->code) && $obj->code == 'RECEP') $iserasable=0;
  730. if (isset($obj->code) && $obj->code == 'EF0') $iserasable=0;
  731. if ($obj->type && $obj->type == 'system') $iserasable=0;
  732. if ($iserasable) {
  733. print '<a href="'.$_SERVER["PHP_SELF"].'?'.($page?'page='.$page.'&':'').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.($obj->rowid?$obj->rowid:$obj->code).'&amp;code='.$obj->code.'&amp;id='.$_GET["id"].'&amp;action='.$acts[$obj->active].'">'.$actl[$obj->active].'</a>';
  734. } else {
  735. print $langs->trans("AlwaysActive");
  736. }
  737. print "</td>";
  738. // Modify link
  739. if ($iserasable) {
  740. print '<td align="center"><a href="'.$_SERVER["PHP_SELF"].'?'.($page?'page='.$page.'&':'').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.($obj->rowid?$obj->rowid:$obj->code).'&amp;code='.$obj->code.'&amp;id='.$_GET["id"].'&amp;action=modify#'.($obj->rowid?$obj->rowid:$obj->code).'">'.img_edit().'</a></td>';
  741. } else {
  742. print '<td>&nbsp;</td>';
  743. }
  744. // Delete link
  745. if ($iserasable) {
  746. print '<td align="center"><a href="'.$_SERVER["PHP_SELF"].'?'.($page?'page='.$page.'&':'').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.($obj->rowid?$obj->rowid:$obj->code).'&amp;code='.$obj->code.'&amp;id='.$_GET["id"].'&amp;action=delete">'.img_delete().'</a></td>';
  747. } else {
  748. print '<td>&nbsp;</td>';
  749. }
  750. print "</tr>\n";
  751. }
  752. $i++;
  753. }
  754. }
  755. }
  756. else {
  757. dol_print_error($db);
  758. }
  759. print '</table>';
  760. print '</form>';
  761. }
  762. else
  763. {
  764. /*
  765. * Show list of dictionnary to show
  766. */
  767. $var=true;
  768. $lastlineisempty=false;
  769. print '<table class="noborder" width="100%">';
  770. print '<tr class="liste_titre">';
  771. //print '<td>'.$langs->trans("Module").'</td>';
  772. print '<td colspan="2">'.$langs->trans("Dictionnary").'</td>';
  773. print '<td>'.$langs->trans("Table").'</td>';
  774. print '</tr>';
  775. foreach ($taborder as $i)
  776. {
  777. if ($tabname[$i] && empty($tabcond[$i])) continue;
  778. if ($i)
  779. {
  780. $var=!$var;
  781. $value=$tabname[$i];
  782. print '<tr '.$bc[$var].'><td width="30%">';
  783. if (! empty($tabcond[$i]))
  784. {
  785. print '<a href="dict.php?id='.$i.'">'.$langs->trans($tablib[$i]).'</a>';
  786. }
  787. else
  788. {
  789. print $langs->trans($tablib[$i]);
  790. }
  791. print '</td>';
  792. print '<td>';
  793. /*if (empty($tabcond[$i]))
  794. {
  795. print info_admin($langs->trans("DictionnaryDisabledSinceNoModuleNeedIt"),1);
  796. }*/
  797. print '</td>';
  798. print '<td>'.$tabname[$i].'</td></tr>';
  799. $lastlineisempty=false;
  800. }
  801. else
  802. {
  803. if (! $lastlineisempty)
  804. {
  805. $var=!$var;
  806. print '<tr '.$bc[$var].'><td width="30%">&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>';
  807. $lastlineisempty=true;
  808. }
  809. }
  810. }
  811. print '</table>';
  812. }
  813. print '<br>';
  814. $db->close();
  815. llxFooter();
  816. /**
  817. * \brief Show field
  818. * \param fieldlist Array of fields
  819. * \param obj If we show a particular record, obj is filled with record fields
  820. */
  821. function fieldList($fieldlist,$obj='')
  822. {
  823. global $conf,$langs,$db;
  824. global $region_id;
  825. global $elementList,$sourceList;
  826. $html = new Form($db);
  827. $formadmin = new FormAdmin($db);
  828. $formcompany = new FormCompany($db);
  829. foreach ($fieldlist as $field => $value)
  830. {
  831. if ($fieldlist[$field] == 'pays') {
  832. if (in_array('region_id',$fieldlist)) { print '<td>&nbsp;</td>'; continue; } // For region page, we do not show the country input
  833. print '<td>';
  834. $html->select_pays($obj->pays,'pays');
  835. print '</td>';
  836. }
  837. elseif ($fieldlist[$field] == 'pays_id') {
  838. $pays_id = (! empty($obj->$fieldlist[$field])) ? $obj->$fieldlist[$field] : 0;
  839. print '<input type="hidden" name="'.$fieldlist[$field].'" value="'.$pays_id.'">';
  840. }
  841. elseif ($fieldlist[$field] == 'region') {
  842. print '<td>';
  843. $formcompany->select_region($region_id,'region');
  844. print '</td>';
  845. }
  846. elseif ($fieldlist[$field] == 'region_id') {
  847. $region_id = $obj->$fieldlist[$field]?$obj->$fieldlist[$field]:0;
  848. print '<input type="hidden" name="'.$fieldlist[$field].'" value="'.$region_id.'">';
  849. }
  850. elseif ($fieldlist[$field] == 'lang') {
  851. print '<td>';
  852. print $formadmin->select_language($conf->global->MAIN_LANG_DEFAULT,'lang');
  853. print '</td>';
  854. }
  855. // Le type de l'element (pour les type de contact).'
  856. elseif ($fieldlist[$field] == 'element')
  857. {
  858. print '<td>';
  859. print $html->selectarray('element', $elementList,$obj->$fieldlist[$field]);
  860. print '</td>';
  861. }
  862. // La source de l'element (pour les type de contact).'
  863. elseif ($fieldlist[$field] == 'source')
  864. {
  865. print '<td>';
  866. print $html->selectarray('source', $sourceList,$obj->$fieldlist[$field]);
  867. print '</td>';
  868. }
  869. elseif ($fieldlist[$field] == 'type' && $tabname[$_GET["id"]] == MAIN_DB_PREFIX."c_actioncomm")
  870. {
  871. print '<td>';
  872. print 'user<input type="hidden" name="type" value="user">';
  873. print '</td>';
  874. }
  875. elseif ($fieldlist[$field] == 'recuperableonly' || $fieldlist[$field] == 'fdm') {
  876. print '<td>';
  877. print $html->selectyesno($fieldlist[$field],$obj->$fieldlist[$field],1);
  878. print '</td>';
  879. }
  880. elseif ($fieldlist[$field] == 'nbjour' || $fieldlist[$field] == 'decalage' || $fieldlist[$field] == 'taux') {
  881. print '<td><input type="text" class="flat" value="'.$obj->$fieldlist[$field].'" size="3" name="'.$fieldlist[$field].'"></td>';
  882. }
  883. elseif ($fieldlist[$field] == 'libelle_facture') {
  884. print '<td><textarea cols="30" rows="'.ROWS_2.'" class="flat" name="'.$fieldlist[$field].'">'.$obj->$fieldlist[$field].'</textarea></td>';
  885. }
  886. elseif ($fieldlist[$field] == 'price') {
  887. print '<td><input type="text" class="flat" value="'.price($obj->$fieldlist[$field]).'" size="8" name="'.$fieldlist[$field].'"></td>';
  888. }
  889. elseif ($fieldlist[$field] == 'code') {
  890. print '<td><input type="text" class="flat" value="'.$obj->$fieldlist[$field].'" size="10" name="'.$fieldlist[$field].'"></td>';
  891. }
  892. elseif ($fieldlist[$field]=='unit') {
  893. print '<td>';
  894. print $html->selectarray('unit',array('mm','cm','point','inch'),$obj->$fieldlist[$field],0,0,1);
  895. print '</td>';
  896. }
  897. else
  898. {
  899. print '<td>';
  900. print '<input type="text" '.($fieldlist[$field]=='libelle'?'size="32" ':'').' class="flat" value="'.$obj->$fieldlist[$field].'" name="'.$fieldlist[$field].'">';
  901. print '</td>';
  902. }
  903. }
  904. }
  905. ?>