New: Can add a link or tooltip on fields into dictionnaries.
This commit is contained in:
parent
e543bc1ac4
commit
84a0d93475
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||||
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
|
* Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
|
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
|
||||||
* Copyright (C) 2005-2010 Regis Houssin <regis@dolibarr.fr>
|
* Copyright (C) 2005-2010 Regis Houssin <regis@dolibarr.fr>
|
||||||
* Copyright (C) 2010-2011 Juanjo Menent <jmenent@2byte.es>
|
* Copyright (C) 2010-2011 Juanjo Menent <jmenent@2byte.es>
|
||||||
@ -65,13 +65,14 @@ include_once(DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php');
|
|||||||
$hookmanager=new HookManager($db);
|
$hookmanager=new HookManager($db);
|
||||||
$hookmanager->initHooks(array('admin'));
|
$hookmanager->initHooks(array('admin'));
|
||||||
|
|
||||||
// Thi page is a generic page to edit dictionnaries
|
// This page is a generic page to edit dictionnaries
|
||||||
// Put here delacaration of dictionnaries properties
|
// Put here declaration of dictionnaries properties
|
||||||
|
|
||||||
// Sort order to show dictionnary (0 is space). All other dictionnaries (added by modules) will be at end of this.
|
// Sort order to show dictionnary (0 is space). All other dictionnaries (added by modules) will be at end of this.
|
||||||
$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);
|
$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);
|
||||||
|
|
||||||
// Name of SQL tables of dictionnaries
|
// Name of SQL tables of dictionnaries
|
||||||
|
$tabname=array();
|
||||||
$tabname[1] = MAIN_DB_PREFIX."c_forme_juridique";
|
$tabname[1] = MAIN_DB_PREFIX."c_forme_juridique";
|
||||||
$tabname[2] = MAIN_DB_PREFIX."c_departements";
|
$tabname[2] = MAIN_DB_PREFIX."c_departements";
|
||||||
$tabname[3] = MAIN_DB_PREFIX."c_regions";
|
$tabname[3] = MAIN_DB_PREFIX."c_regions";
|
||||||
@ -96,6 +97,7 @@ $tabname[21]= MAIN_DB_PREFIX."c_availability";
|
|||||||
$tabname[22]= MAIN_DB_PREFIX."c_input_reason";
|
$tabname[22]= MAIN_DB_PREFIX."c_input_reason";
|
||||||
|
|
||||||
// Dictionary labels
|
// Dictionary labels
|
||||||
|
$tablib=array();
|
||||||
$tablib[1] = "DictionnaryCompanyJuridicalType";
|
$tablib[1] = "DictionnaryCompanyJuridicalType";
|
||||||
$tablib[2] = "DictionnaryCanton";
|
$tablib[2] = "DictionnaryCanton";
|
||||||
$tablib[3] = "DictionnaryRegion";
|
$tablib[3] = "DictionnaryRegion";
|
||||||
@ -120,6 +122,7 @@ $tablib[21]= "DictionnaryAvailability";
|
|||||||
$tablib[22]= "DictionnarySource";
|
$tablib[22]= "DictionnarySource";
|
||||||
|
|
||||||
// Requete pour extraction des donnees des dictionnaires
|
// Requete pour extraction des donnees des dictionnaires
|
||||||
|
$tabsql=array();
|
||||||
$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";
|
$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";
|
||||||
$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";
|
$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";
|
||||||
$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";
|
$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";
|
||||||
@ -144,6 +147,7 @@ $tabsql[21]= "SELECT c.rowid as rowid, code, label, active FROM ".MAIN_DB_PREFIX
|
|||||||
$tabsql[22]= "SELECT rowid as rowid, code, label, active FROM ".MAIN_DB_PREFIX."c_input_reason";
|
$tabsql[22]= "SELECT rowid as rowid, code, label, active FROM ".MAIN_DB_PREFIX."c_input_reason";
|
||||||
|
|
||||||
// Critere de tri du dictionnaire
|
// Critere de tri du dictionnaire
|
||||||
|
$tabsqlsort=array();
|
||||||
$tabsqlsort[1] ="pays ASC, code ASC";
|
$tabsqlsort[1] ="pays ASC, code ASC";
|
||||||
$tabsqlsort[2] ="pays ASC, code ASC";
|
$tabsqlsort[2] ="pays ASC, code ASC";
|
||||||
$tabsqlsort[3] ="pays ASC, code ASC";
|
$tabsqlsort[3] ="pays ASC, code ASC";
|
||||||
@ -168,6 +172,7 @@ $tabsqlsort[21]="code ASC, label ASC";
|
|||||||
$tabsqlsort[22]="code ASC, label ASC";
|
$tabsqlsort[22]="code ASC, label ASC";
|
||||||
|
|
||||||
// Nom des champs en resultat de select pour affichage du dictionnaire
|
// Nom des champs en resultat de select pour affichage du dictionnaire
|
||||||
|
$tabfield=array();
|
||||||
$tabfield[1] = "code,libelle,pays";
|
$tabfield[1] = "code,libelle,pays";
|
||||||
$tabfield[2] = "code,libelle,region_id,region,pays"; // "code,libelle,region,pays_code-pays"
|
$tabfield[2] = "code,libelle,region_id,region,pays"; // "code,libelle,region,pays_code-pays"
|
||||||
$tabfield[3] = "code,libelle,pays_id,pays";
|
$tabfield[3] = "code,libelle,pays_id,pays";
|
||||||
@ -192,6 +197,7 @@ $tabfield[21]= "code,label";
|
|||||||
$tabfield[22]= "code,label";
|
$tabfield[22]= "code,label";
|
||||||
|
|
||||||
// Nom des champs d'edition pour modification d'un enregistrement
|
// Nom des champs d'edition pour modification d'un enregistrement
|
||||||
|
$tabfieldvalue=array();
|
||||||
$tabfieldvalue[1] = "code,libelle,pays";
|
$tabfieldvalue[1] = "code,libelle,pays";
|
||||||
$tabfieldvalue[2] = "code,libelle,region"; // "code,libelle,region"
|
$tabfieldvalue[2] = "code,libelle,region"; // "code,libelle,region"
|
||||||
$tabfieldvalue[3] = "code,libelle,pays";
|
$tabfieldvalue[3] = "code,libelle,pays";
|
||||||
@ -216,6 +222,7 @@ $tabfieldvalue[21]= "code,label";
|
|||||||
$tabfieldvalue[22]= "code,label";
|
$tabfieldvalue[22]= "code,label";
|
||||||
|
|
||||||
// Nom des champs dans la table pour insertion d'un enregistrement
|
// Nom des champs dans la table pour insertion d'un enregistrement
|
||||||
|
$tabfieldinsert=array();
|
||||||
$tabfieldinsert[1] = "code,libelle,fk_pays";
|
$tabfieldinsert[1] = "code,libelle,fk_pays";
|
||||||
$tabfieldinsert[2] = "code_departement,nom,fk_region";
|
$tabfieldinsert[2] = "code_departement,nom,fk_region";
|
||||||
$tabfieldinsert[3] = "code_region,nom,fk_pays";
|
$tabfieldinsert[3] = "code_region,nom,fk_pays";
|
||||||
@ -242,6 +249,7 @@ $tabfieldinsert[22]= "code,label";
|
|||||||
// Nom du rowid si le champ n'est pas de type autoincrement
|
// Nom du rowid si le champ n'est pas de type autoincrement
|
||||||
// Example: "" if id field is "rowid" and has autoincrement on
|
// Example: "" if id field is "rowid" and has autoincrement on
|
||||||
// "nameoffield" if id field is not "rowid" or has not autoincrement on
|
// "nameoffield" if id field is not "rowid" or has not autoincrement on
|
||||||
|
$tabrowid=array();
|
||||||
$tabrowid[1] = "";
|
$tabrowid[1] = "";
|
||||||
$tabrowid[2] = "";
|
$tabrowid[2] = "";
|
||||||
$tabrowid[3] = "";
|
$tabrowid[3] = "";
|
||||||
@ -266,6 +274,7 @@ $tabrowid[21]= "rowid";
|
|||||||
$tabrowid[22]= "rowid";
|
$tabrowid[22]= "rowid";
|
||||||
|
|
||||||
// Condition to show dictionnary in setup page
|
// Condition to show dictionnary in setup page
|
||||||
|
$tabcond=array();
|
||||||
$tabcond[1] = true;
|
$tabcond[1] = true;
|
||||||
$tabcond[2] = true;
|
$tabcond[2] = true;
|
||||||
$tabcond[3] = true;
|
$tabcond[3] = true;
|
||||||
@ -289,8 +298,34 @@ $tabcond[20]= $conf->fournisseur->enabled;
|
|||||||
$tabcond[21]= $conf->propal->enabled;
|
$tabcond[21]= $conf->propal->enabled;
|
||||||
$tabcond[22]= $conf->commande->enabled||$conf->propal->enabled;
|
$tabcond[22]= $conf->commande->enabled||$conf->propal->enabled;
|
||||||
|
|
||||||
|
// List of help for fields
|
||||||
|
$tabhelp=array();
|
||||||
|
$tabhelp[1] = array();
|
||||||
|
$tabhelp[2] = array();
|
||||||
|
$tabhelp[3] = array();
|
||||||
|
$tabhelp[4] = array();
|
||||||
|
$tabhelp[5] = array();
|
||||||
|
$tabhelp[6] = array();
|
||||||
|
$tabhelp[7] = array();
|
||||||
|
$tabhelp[8] = array();
|
||||||
|
$tabhelp[9] = array();
|
||||||
|
$tabhelp[10] = array();
|
||||||
|
$tabhelp[11] = array();
|
||||||
|
$tabhelp[12] = array();
|
||||||
|
$tabhelp[13] = array();
|
||||||
|
$tabhelp[14] = array();
|
||||||
|
$tabhelp[15] = array();
|
||||||
|
$tabhelp[16] = array();
|
||||||
|
$tabhelp[17] = array();
|
||||||
|
$tabhelp[18] = array();
|
||||||
|
$tabhelp[19] = array();
|
||||||
|
$tabhelp[20] = array();
|
||||||
|
$tabhelp[21] = array();
|
||||||
|
$tabhelp[22] = array();
|
||||||
|
|
||||||
|
// Complete all arrays with entries found into modules
|
||||||
|
complete_dictionnary_with_modules($taborder,$tabname,$tablib,$tabsql,$tabsqlsort,$tabfield,$tabfieldvalue,$tabfieldinsert,$tabrowid,$tabcond,$tabhelp);
|
||||||
|
|
||||||
complete_dictionnary_with_modules($taborder,$tabname,$tablib,$tabsql,$tabsqlsort,$tabfield,$tabfieldvalue,$tabfieldinsert,$tabrowid,$tabcond);
|
|
||||||
|
|
||||||
// Define elementList and sourceList (used for dictionnary "type of contacts")
|
// Define elementList and sourceList (used for dictionnary "type of contacts")
|
||||||
$elementList = array();
|
$elementList = array();
|
||||||
@ -320,9 +355,7 @@ if ($id == 11)
|
|||||||
$msg='';
|
$msg='';
|
||||||
|
|
||||||
|
|
||||||
/*
|
// Actions ajout ou modification d'une entree dans un dictionnaire de donnee
|
||||||
* Actions ajout ou modification d'une entree dans un dictionnaire de donnee
|
|
||||||
*/
|
|
||||||
if ($_POST["actionadd"] || $_POST["actionmodify"])
|
if ($_POST["actionadd"] || $_POST["actionmodify"])
|
||||||
{
|
{
|
||||||
$listfield=explode(',',$tabfield[$id]);
|
$listfield=explode(',',$tabfield[$id]);
|
||||||
@ -503,7 +536,8 @@ if ($action == 'confirm_delete' && $confirm == 'yes') // delete
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($action == $acts[0]) // activate
|
// activate
|
||||||
|
if ($action == $acts[0])
|
||||||
{
|
{
|
||||||
if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; }
|
if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; }
|
||||||
else { $rowidcol="rowid"; }
|
else { $rowidcol="rowid"; }
|
||||||
@ -522,7 +556,8 @@ if ($action == $acts[0]) // activate
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($action == $acts[1]) // disable
|
// disable
|
||||||
|
if ($action == $acts[1])
|
||||||
{
|
{
|
||||||
if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; }
|
if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; }
|
||||||
else { $rowidcol="rowid"; }
|
else { $rowidcol="rowid"; }
|
||||||
@ -568,9 +603,7 @@ if (empty($id))
|
|||||||
print "<br>\n";
|
print "<br>\n";
|
||||||
|
|
||||||
|
|
||||||
/*
|
// Confirmation de la suppression de la ligne
|
||||||
* Confirmation de la suppression de la ligne
|
|
||||||
*/
|
|
||||||
if ($action == 'delete')
|
if ($action == 'delete')
|
||||||
{
|
{
|
||||||
$ret=$form->form_confirm($_SERVER["PHP_SELF"].'?'.($page?'page='.$page.'&':'').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.$rowid.'&code='.$_GET["code"].'&id='.$id, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_delete','',0,1);
|
$ret=$form->form_confirm($_SERVER["PHP_SELF"].'?'.($page?'page='.$page.'&':'').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.$rowid.'&code='.$_GET["code"].'&id='.$id, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_delete','',0,1);
|
||||||
@ -620,7 +653,6 @@ if ($id)
|
|||||||
$var=false;
|
$var=false;
|
||||||
|
|
||||||
$fieldlist=explode(',',$tabfield[$id]);
|
$fieldlist=explode(',',$tabfield[$id]);
|
||||||
// print '<table class="noborder" width="100%">';
|
|
||||||
|
|
||||||
// Line for title
|
// Line for title
|
||||||
print '<tr class="liste_titre">';
|
print '<tr class="liste_titre">';
|
||||||
@ -655,7 +687,9 @@ if ($id)
|
|||||||
if ($valuetoshow != '')
|
if ($valuetoshow != '')
|
||||||
{
|
{
|
||||||
print '<td>';
|
print '<td>';
|
||||||
print $valuetoshow;
|
if (preg_match('/http:/i',$tabhelp[$id][$value])) print '<a href="'.$tabhelp[$id][$value].'" target="_blank">'.$valuetoshow.'</a>';
|
||||||
|
else if (! empty($tabhelp[$id][$value])) print $form->textwithpicto($valuetoshow,$tabhelp[$id][$value]);
|
||||||
|
else print $valuetoshow;
|
||||||
print '</td>';
|
print '</td>';
|
||||||
}
|
}
|
||||||
if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') $alabelisused=1;
|
if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') $alabelisused=1;
|
||||||
@ -746,10 +780,10 @@ if ($id)
|
|||||||
// Affiche nom du champ
|
// Affiche nom du champ
|
||||||
if ($showfield)
|
if ($showfield)
|
||||||
{
|
{
|
||||||
print_liste_field_titre($valuetoshow,"dict.php",$fieldlist[$field],($page?'page='.$page.'&':'').'&id='.$id,"","",$sortfield,$sortorder);
|
print_liste_field_titre($valuetoshow,$_SERVER["PHP_SELF"],$fieldlist[$field],($page?'page='.$page.'&':'').'&id='.$id,"","",$sortfield,$sortorder);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
print_liste_field_titre($langs->trans("Status"),"dict.php","active",($page?'page='.$page.'&':'').'&id='.$id,"",'align="center"',$sortfield,$sortorder);
|
print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"active",($page?'page='.$page.'&':'').'&id='.$id,"",'align="center"',$sortfield,$sortorder);
|
||||||
print '<td colspan="2" class="liste_titre"> </td>';
|
print '<td colspan="2" class="liste_titre"> </td>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
|
|
||||||
|
|||||||
@ -846,9 +846,10 @@ function unActivateModule($value, $requiredby=1)
|
|||||||
* @param array &$tabfieldinsert Tabfieldinsert
|
* @param array &$tabfieldinsert Tabfieldinsert
|
||||||
* @param array &$tabrowid Tabrowid
|
* @param array &$tabrowid Tabrowid
|
||||||
* @param array &$tabcond Tabcond
|
* @param array &$tabcond Tabcond
|
||||||
|
* @param array &$tabhelp Tabhelp
|
||||||
* @return int 1
|
* @return int 1
|
||||||
*/
|
*/
|
||||||
function complete_dictionnary_with_modules(&$taborder,&$tabname,&$tablib,&$tabsql,&$tabsqlsort,&$tabfield,&$tabfieldvalue,&$tabfieldinsert,&$tabrowid,&$tabcond)
|
function complete_dictionnary_with_modules(&$taborder,&$tabname,&$tablib,&$tabsql,&$tabsqlsort,&$tabfield,&$tabfieldvalue,&$tabfieldinsert,&$tabrowid,&$tabcond,&$tabhelp)
|
||||||
{
|
{
|
||||||
global $db, $modules, $conf, $langs;
|
global $db, $modules, $conf, $langs;
|
||||||
|
|
||||||
@ -959,6 +960,7 @@ function complete_dictionnary_with_modules(&$taborder,&$tabname,&$tablib,&$tabsq
|
|||||||
foreach($objMod->dictionnaries['tabfieldinsert'] as $val) $tabfieldinsert[] = $val;
|
foreach($objMod->dictionnaries['tabfieldinsert'] as $val) $tabfieldinsert[] = $val;
|
||||||
foreach($objMod->dictionnaries['tabrowid'] as $val) $tabrowid[] = $val;
|
foreach($objMod->dictionnaries['tabrowid'] as $val) $tabrowid[] = $val;
|
||||||
foreach($objMod->dictionnaries['tabcond'] as $val) $tabcond[] = $val;
|
foreach($objMod->dictionnaries['tabcond'] as $val) $tabcond[] = $val;
|
||||||
|
if (! empty($objMod->dictionnaries['tabhelp'])) foreach($objMod->dictionnaries['tabhelp'] as $val) $tabhelp[] = $val;
|
||||||
//foreach($objMod->dictionnaries['tabsqlsort'] as $val) $tablib[] = $val;
|
//foreach($objMod->dictionnaries['tabsqlsort'] as $val) $tablib[] = $val;
|
||||||
//$tabname = array_merge ($tabname, $objMod->dictionnaries['tabname']);
|
//$tabname = array_merge ($tabname, $objMod->dictionnaries['tabname']);
|
||||||
//var_dump($tabcond);
|
//var_dump($tabcond);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user