Add dictionary to define type of resources
This commit is contained in:
parent
3e522b1f54
commit
5f74b86b18
@ -70,7 +70,7 @@ $hookmanager->initHooks(array('admin'));
|
||||
// Put here declaration of dictionaries properties
|
||||
|
||||
// Sort order to show dictionary (0 is space). All other dictionaries (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,25,12,13,0,14,0,7,17,0,22,20,18,21,0,15,0,24,23);
|
||||
$taborder=array(9,0,4,3,2,0,1,8,19,16,0,5,11,0,6,0,10,25,12,13,0,14,0,7,17,0,22,20,18,21,0,15,0,24,23,0,26);
|
||||
|
||||
// Name of SQL tables of dictionaries
|
||||
$tabname=array();
|
||||
@ -99,6 +99,7 @@ $tabname[22]= MAIN_DB_PREFIX."c_input_reason";
|
||||
$tabname[23]= MAIN_DB_PREFIX."accountingaccount";
|
||||
$tabname[24]= MAIN_DB_PREFIX."accounting_system";
|
||||
$tabname[25]= MAIN_DB_PREFIX."c_revenuestamp";
|
||||
$tabname[26]= MAIN_DB_PREFIX."c_type_resource";
|
||||
|
||||
// Dictionary labels
|
||||
$tablib=array();
|
||||
@ -127,6 +128,7 @@ $tablib[22]= "DictionarySource";
|
||||
$tablib[23]= "DictionaryAccountancyplan";
|
||||
$tablib[24]= "DictionaryAccountancysystem";
|
||||
$tablib[25]= "DictionaryRevenueStamp";
|
||||
$tablib[26]= "DictionaryResourceType";
|
||||
|
||||
// Requete pour extraction des donnees des dictionnaires
|
||||
$tabsql=array();
|
||||
@ -155,6 +157,7 @@ $tabsql[22]= "SELECT rowid as rowid, code, label, active FROM ".MAIN_DB_PREFIX
|
||||
$tabsql[23]= "SELECT rowid as rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number as accountancy_code, account_parent, label, active FROM ".MAIN_DB_PREFIX."accountingaccount";
|
||||
$tabsql[24]= "SELECT s.rowid as rowid, pcg_version, s.fk_pays as country_id, p.code as country_code, p.libelle as pays, s.label, s.active FROM ".MAIN_DB_PREFIX."accounting_system as s, ".MAIN_DB_PREFIX."c_pays as p WHERE s.fk_pays=p.rowid and p.active=1";
|
||||
$tabsql[25]= "SELECT t.rowid, t.taux, p.libelle as country, p.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_pays as p WHERE t.fk_pays=p.rowid";
|
||||
$tabsql[26]= "SELECT rowid as rowid, code, label, active FROM ".MAIN_DB_PREFIX."c_type_resource";
|
||||
|
||||
// Critere de tri du dictionnaire
|
||||
$tabsqlsort=array();
|
||||
@ -183,6 +186,7 @@ $tabsqlsort[22]="code ASC, label ASC";
|
||||
$tabsqlsort[23]="fk_pcg_version ASC, accountancy_code ASC";
|
||||
$tabsqlsort[24]="pcg_version ASC";
|
||||
$tabsqlsort[25]="country ASC, taux ASC";
|
||||
$tabsqlsort[26]="code ASC,label ASC";
|
||||
|
||||
// Nom des champs en resultat de select pour affichage du dictionnaire
|
||||
$tabfield=array();
|
||||
@ -211,6 +215,7 @@ $tabfield[22]= "code,label";
|
||||
$tabfield[23]= "fk_pcg_version,accountancy_code,account_parent,pcg_type,pcg_subtype,label";
|
||||
$tabfield[24]= "pcg_version,country_id,country,label";
|
||||
$tabfield[25]= "country_id,country,taux,accountancy_code_sell,accountancy_code_buy,note";
|
||||
$tabfield[26]= "code,label";
|
||||
|
||||
// Nom des champs d'edition pour modification d'un enregistrement
|
||||
$tabfieldvalue=array();
|
||||
@ -239,6 +244,7 @@ $tabfieldvalue[22]= "code,label";
|
||||
$tabfieldvalue[23]= "fk_pcg_version,accountancy_code,account_parent,pcg_type,pcg_subtype,label";
|
||||
$tabfieldvalue[24]= "pcg_version,country,label";
|
||||
$tabfieldvalue[25]= "country,taux,accountancy_code_sell,accountancy_code_buy,note";
|
||||
$tabfieldvalue[26]= "code,label";
|
||||
|
||||
// Nom des champs dans la table pour insertion d'un enregistrement
|
||||
$tabfieldinsert=array();
|
||||
@ -267,6 +273,7 @@ $tabfieldinsert[22]= "code,label";
|
||||
$tabfieldinsert[23]= "fk_pcg_version,account_number,account_parent,pcg_type,pcg_subtype,label";
|
||||
$tabfieldinsert[24]= "pcg_version,fk_pays,label";
|
||||
$tabfieldinsert[25]= "fk_pays,taux,accountancy_code_sell,accountancy_code_buy,note";
|
||||
$tabfieldinsert[26]= "code,label";
|
||||
|
||||
// Nom du rowid si le champ n'est pas de type autoincrement
|
||||
// Example: "" if id field is "rowid" and has autoincrement on
|
||||
@ -297,6 +304,7 @@ $tabrowid[22]= "rowid";
|
||||
$tabrowid[23]= "";
|
||||
$tabrowid[24]= "";
|
||||
$tabrowid[25]= "";
|
||||
$tabrowid[25]= "";
|
||||
|
||||
// Condition to show dictionary in setup page
|
||||
$tabcond=array();
|
||||
@ -325,6 +333,7 @@ $tabcond[22]= (! empty($conf->commande->enabled) || ! empty($conf->propal->enabl
|
||||
$tabcond[23]= (! empty($conf->global->ACCOUNTING_USEDICTTOEDIT) && ! empty($conf->accounting->enabled)); // The accountancy plan should be edited with specific pages. You can set ACCOUNTING_USEDICTTOEDIT to 1 if you want to use dictionary editor.
|
||||
$tabcond[24]= (! empty($conf->global->ACCOUNTING_USEDICTTOEDIT) && ! empty($conf->accounting->enabled)); // The accountancy system should be edited with specific pages. You can set ACCOUNTING_USEDICTTOEDIT to 1 if you want to use dictionary editor.
|
||||
$tabcond[25]= true;
|
||||
$tabcond[26]= ! empty($conf->resource->enabled);
|
||||
|
||||
// List of help for fields
|
||||
$tabhelp=array();
|
||||
@ -353,6 +362,7 @@ $tabhelp[22] = array();
|
||||
$tabhelp[23] = array();
|
||||
$tabhelp[24] = array();
|
||||
$tabhelp[25] = array();
|
||||
$tabhelp[26] = array();
|
||||
|
||||
// Complete all arrays with entries found into modules
|
||||
complete_dictionary_with_modules($taborder,$tabname,$tablib,$tabsql,$tabsqlsort,$tabfield,$tabfieldvalue,$tabfieldinsert,$tabrowid,$tabcond,$tabhelp);
|
||||
|
||||
@ -1187,3 +1187,13 @@ CREATE TABLE llx_element_resources
|
||||
ALTER TABLE llx_element_resources ADD UNIQUE INDEX idx_element_resources_idx1 (resource_id, resource_type, element_id, element_type);
|
||||
ALTER TABLE llx_element_resources ADD INDEX idx_element_element_element_id (element_id);
|
||||
-- Pas de contraite sur resource_id et element_id car pointe sur differentes tables
|
||||
|
||||
create table llx_c_type_resource
|
||||
(
|
||||
rowid integer PRIMARY KEY,
|
||||
code varchar(32) NOT NULL,
|
||||
label varchar(64) NOT NULL,
|
||||
active tinyint DEFAULT 1 NOT NULL
|
||||
)ENGINE=innodb;
|
||||
|
||||
ALTER TABLE llx_c_type_resource ADD UNIQUE INDEX uk_c_type_resource_id (label, code);
|
||||
|
||||
@ -29,4 +29,6 @@ TitleResourceCard=Resource card
|
||||
ResourceSingular=Resource
|
||||
|
||||
ResourceName=Resource name
|
||||
ResourceType=Resource type
|
||||
ResourceType=Type of resource
|
||||
|
||||
DictionaryResourceType=Type of resources
|
||||
@ -677,7 +677,7 @@ class Resource extends CommonObject
|
||||
|
||||
if (count($this->cache_code_type_resource)) return 0; // Cache deja charge
|
||||
|
||||
$sql = "SELECT rowid, code, libelle, active";
|
||||
$sql = "SELECT rowid, code, label, active";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."c_type_resource";
|
||||
$sql.= " WHERE active > 0";
|
||||
$sql.= " ORDER BY rowid";
|
||||
@ -691,9 +691,9 @@ class Resource extends CommonObject
|
||||
{
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
// Si traduction existe, on l'utilise, sinon on prend le libelle par defaut
|
||||
$label=($langs->trans("ResourceTypeShort".$obj->code)!=("ResourceTypeShort".$obj->code)?$langs->trans("ResourceTypeShort".$obj->code):($obj->libelle!='-'?$obj->libelle:''));
|
||||
$label=($langs->trans("ResourceTypeShort".$obj->code)!=("ResourceTypeShort".$obj->code)?$langs->trans("ResourceTypeShort".$obj->code):($obj->label!='-'?$obj->label:''));
|
||||
$this->cache_code_type_resource[$obj->rowid]['code'] =$obj->code;
|
||||
$this->cache_code_type_resource[$obj->rowid]['libelle']=$label;
|
||||
$this->cache_code_type_resource[$obj->rowid]['label']=$label;
|
||||
$this->cache_code_type_resource[$obj->rowid]['active'] =$obj->active;
|
||||
$i++;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user